teleton 0.8.1 → 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 (43) hide show
  1. package/dist/bootstrap-DDFVEMYI.js +128 -0
  2. package/dist/{server-3FHI2SEB.js → chunk-2ERTYRHA.js} +26 -372
  3. package/dist/{chunk-5FNWBZ5K.js → chunk-33Z47EXI.js} +264 -274
  4. package/dist/{chunk-3S4GGLLR.js → chunk-35MX4ZUI.js} +23 -104
  5. package/dist/chunk-3UFPFWYP.js +12 -0
  6. package/dist/chunk-5SEMA47R.js +75 -0
  7. package/dist/{chunk-PHSAHTK4.js → chunk-6OOHHJ4N.js} +3 -108
  8. package/dist/{chunk-CGOXE4WP.js → chunk-7MWKT67G.js} +467 -914
  9. package/dist/chunk-AEHTQI3H.js +142 -0
  10. package/dist/{chunk-S6PHGKOC.js → chunk-AERHOXGC.js} +88 -322
  11. package/dist/chunk-ALKAAG4O.js +487 -0
  12. package/dist/{chunk-UP55PXFH.js → chunk-C4NKJT2Z.js} +8 -0
  13. package/dist/chunk-CUE4UZXR.js +129 -0
  14. package/dist/chunk-FUNF6H4W.js +251 -0
  15. package/dist/{chunk-7U7BOHCL.js → chunk-GHMXWAXI.js} +147 -63
  16. package/dist/{chunk-QBHRXLZS.js → chunk-H7MFXJZK.js} +2 -2
  17. package/dist/{chunk-QV2GLOTK.js → chunk-LC4TV3KL.js} +1 -1
  18. package/dist/{chunk-AYWEJCDB.js → chunk-LVTKJQ7O.js} +12 -10
  19. package/dist/{chunk-RCMD3U65.js → chunk-NQ6FZKCE.js} +13 -0
  20. package/dist/chunk-NVKBBTI6.js +128 -0
  21. package/dist/{setup-server-32XGDPE6.js → chunk-OIMAE24Q.js} +55 -216
  22. package/dist/{chunk-OJCLKU5Z.js → chunk-WFTC3JJW.js} +16 -0
  23. package/dist/chunk-WTDAICGT.js +175 -0
  24. package/dist/{chunk-KVXV7EF7.js → chunk-XDZDOKIF.js} +2 -2
  25. package/dist/cli/index.js +91 -27
  26. package/dist/{client-MPHPIZB6.js → client-5KD25NOP.js} +5 -4
  27. package/dist/{get-my-gifts-CC6HAVWB.js → get-my-gifts-Y7EN7RK4.js} +3 -3
  28. package/dist/index.js +19 -13
  29. package/dist/local-IHKJFQJS.js +9 -0
  30. package/dist/{memory-UBHM7ILG.js → memory-QMJRM3XJ.js} +9 -5
  31. package/dist/memory-hook-VUNWZ3NY.js +19 -0
  32. package/dist/{migrate-UBBEJ5BL.js → migrate-5VBAP52B.js} +5 -4
  33. package/dist/server-JF6FX772.js +813 -0
  34. package/dist/server-N4T7E25M.js +396 -0
  35. package/dist/setup-server-IX3BFPPH.js +217 -0
  36. package/dist/{store-M5IMUQCL.js → store-BY7S6IFN.js} +6 -5
  37. package/dist/{task-dependency-resolver-RR2O5S7B.js → task-dependency-resolver-L6UUMTHK.js} +2 -2
  38. package/dist/{task-executor-6W5HRX5C.js → task-executor-XBNJLUCS.js} +2 -2
  39. package/dist/{tool-adapter-IH5VGBOO.js → tool-adapter-IVX2XQJE.js} +1 -1
  40. package/dist/{tool-index-PMAOXWUA.js → tool-index-FTERJSZK.js} +4 -3
  41. package/dist/{transcript-NGDPSNIH.js → transcript-IM7G25OS.js} +2 -2
  42. package/package.json +4 -2
  43. package/dist/chunk-XBE4JB7C.js +0 -8
@@ -0,0 +1,396 @@
1
+ import {
2
+ createConfigRoutes,
3
+ createHooksRoutes,
4
+ createLogsRoutes,
5
+ createMarketplaceRoutes,
6
+ createMcpRoutes,
7
+ createMemoryRoutes,
8
+ createPluginsRoutes,
9
+ createSoulRoutes,
10
+ createStatusRoutes,
11
+ createTasksRoutes,
12
+ createTonProxyRoutes,
13
+ createToolsRoutes,
14
+ createWorkspaceRoutes,
15
+ logInterceptor
16
+ } from "./chunk-2ERTYRHA.js";
17
+ import "./chunk-WFTC3JJW.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";
25
+ import "./chunk-3UFPFWYP.js";
26
+ import "./chunk-7TECSLJ4.js";
27
+ import "./chunk-35MX4ZUI.js";
28
+ import "./chunk-VFA7QMCZ.js";
29
+ import "./chunk-C4NKJT2Z.js";
30
+ import "./chunk-LVTKJQ7O.js";
31
+ import "./chunk-WTDAICGT.js";
32
+ import "./chunk-6OOHHJ4N.js";
33
+ import "./chunk-XQUHC3JZ.js";
34
+ import "./chunk-R4YSJ4EY.js";
35
+ import "./chunk-LC4TV3KL.js";
36
+ import "./chunk-CUE4UZXR.js";
37
+ import "./chunk-EYWNOHMJ.js";
38
+ import {
39
+ createLogger
40
+ } from "./chunk-NQ6FZKCE.js";
41
+ import "./chunk-4L66JHQE.js";
42
+ import "./chunk-3RG5ZIWI.js";
43
+
44
+ // src/webui/server.ts
45
+ import { Hono } from "hono";
46
+ import { serve } from "@hono/node-server";
47
+ import { cors } from "hono/cors";
48
+ import { streamSSE } from "hono/streaming";
49
+ import { bodyLimit } from "hono/body-limit";
50
+ import { setCookie, getCookie, deleteCookie } from "hono/cookie";
51
+ import { existsSync, readFileSync } from "fs";
52
+ import { join, dirname, resolve, relative } from "path";
53
+ import { fileURLToPath } from "url";
54
+
55
+ // src/webui/middleware/auth.ts
56
+ import { randomBytes, timingSafeEqual } from "crypto";
57
+ var COOKIE_NAME = "teleton_session";
58
+ var COOKIE_MAX_AGE = 7 * 24 * 60 * 60;
59
+ function generateToken() {
60
+ return randomBytes(32).toString("base64url");
61
+ }
62
+ function maskToken(token) {
63
+ if (token.length < 12) return "****";
64
+ return `${token.slice(0, 4)}...${token.slice(-4)}`;
65
+ }
66
+ function safeCompare(a, b) {
67
+ if (!a || !b) return false;
68
+ const bufA = Buffer.from(a);
69
+ const bufB = Buffer.from(b);
70
+ if (bufA.length !== bufB.length) return false;
71
+ return timingSafeEqual(bufA, bufB);
72
+ }
73
+
74
+ // src/webui/server.ts
75
+ var log = createLogger("WebUI");
76
+ function findWebDist() {
77
+ const candidates = [
78
+ resolve("dist/web"),
79
+ // npm start / teleton start (from project root)
80
+ resolve("web")
81
+ // fallback
82
+ ];
83
+ const __dirname = dirname(fileURLToPath(import.meta.url));
84
+ candidates.push(
85
+ resolve(__dirname, "web"),
86
+ // dist/web when __dirname = dist/
87
+ resolve(__dirname, "../dist/web")
88
+ // when running with tsx from src/
89
+ );
90
+ for (const candidate of candidates) {
91
+ if (existsSync(join(candidate, "index.html"))) {
92
+ return candidate;
93
+ }
94
+ }
95
+ return null;
96
+ }
97
+ var WebUIServer = class {
98
+ app;
99
+ server = null;
100
+ deps;
101
+ authToken;
102
+ constructor(deps) {
103
+ this.deps = deps;
104
+ this.app = new Hono();
105
+ this.authToken = deps.config.auth_token || generateToken();
106
+ this.setupMiddleware();
107
+ this.setupRoutes();
108
+ }
109
+ /** Set an HttpOnly session cookie */
110
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Hono context type
111
+ setSessionCookie(c) {
112
+ setCookie(c, COOKIE_NAME, this.authToken, {
113
+ path: "/",
114
+ httpOnly: true,
115
+ sameSite: "Strict",
116
+ secure: false,
117
+ // localhost is HTTP
118
+ maxAge: COOKIE_MAX_AGE
119
+ });
120
+ }
121
+ setupMiddleware() {
122
+ this.app.use(
123
+ "*",
124
+ cors({
125
+ origin: this.deps.config.cors_origins,
126
+ credentials: true,
127
+ allowMethods: ["GET", "HEAD", "PUT", "POST", "DELETE", "PATCH"],
128
+ allowHeaders: ["Content-Type", "Authorization"],
129
+ maxAge: 3600
130
+ })
131
+ );
132
+ if (this.deps.config.log_requests) {
133
+ this.app.use("*", async (c, next) => {
134
+ const start = Date.now();
135
+ await next();
136
+ const duration = Date.now() - start;
137
+ log.info(`${c.req.method} ${c.req.path} \u2192 ${c.res.status} (${duration}ms)`);
138
+ });
139
+ }
140
+ this.app.use(
141
+ "*",
142
+ bodyLimit({
143
+ maxSize: 2 * 1024 * 1024,
144
+ // 2MB
145
+ onError: (c) => c.json({ success: false, error: "Request body too large (max 2MB)" }, 413)
146
+ })
147
+ );
148
+ this.app.use("*", async (c, next) => {
149
+ await next();
150
+ c.res.headers.set("X-Content-Type-Options", "nosniff");
151
+ c.res.headers.set("X-Frame-Options", "DENY");
152
+ c.res.headers.set("Referrer-Policy", "strict-origin-when-cross-origin");
153
+ });
154
+ this.app.use("/api/*", async (c, next) => {
155
+ const cookieToken = getCookie(c, COOKIE_NAME);
156
+ if (cookieToken && safeCompare(cookieToken, this.authToken)) {
157
+ return next();
158
+ }
159
+ const authHeader = c.req.header("Authorization");
160
+ if (authHeader) {
161
+ const match = authHeader.match(/^Bearer\s+(.+)$/i);
162
+ if (match && safeCompare(match[1], this.authToken)) {
163
+ return next();
164
+ }
165
+ }
166
+ const queryToken = c.req.query("token");
167
+ if (queryToken && safeCompare(queryToken, this.authToken)) {
168
+ return next();
169
+ }
170
+ return c.json({ success: false, error: "Unauthorized" }, 401);
171
+ });
172
+ }
173
+ setupRoutes() {
174
+ this.app.get("/health", (c) => c.json({ status: "ok" }));
175
+ this.app.get("/auth/exchange", (c) => {
176
+ const token = c.req.query("token");
177
+ if (!token || !safeCompare(token, this.authToken)) {
178
+ return c.json({ success: false, error: "Invalid token" }, 401);
179
+ }
180
+ this.setSessionCookie(c);
181
+ return c.redirect("/");
182
+ });
183
+ this.app.post("/auth/login", async (c) => {
184
+ try {
185
+ const body = await c.req.json();
186
+ if (!body.token || !safeCompare(body.token, this.authToken)) {
187
+ return c.json({ success: false, error: "Invalid token" }, 401);
188
+ }
189
+ this.setSessionCookie(c);
190
+ return c.json({ success: true });
191
+ } catch {
192
+ return c.json({ success: false, error: "Invalid request body" }, 400);
193
+ }
194
+ });
195
+ this.app.post("/auth/logout", (c) => {
196
+ deleteCookie(c, COOKIE_NAME, { path: "/" });
197
+ return c.json({ success: true });
198
+ });
199
+ this.app.get("/auth/check", (c) => {
200
+ const cookieToken = getCookie(c, COOKIE_NAME);
201
+ const authenticated = !!(cookieToken && safeCompare(cookieToken, this.authToken));
202
+ return c.json({ success: true, data: { authenticated } });
203
+ });
204
+ this.app.route("/api/status", createStatusRoutes(this.deps));
205
+ this.app.route("/api/tools", createToolsRoutes(this.deps));
206
+ this.app.route("/api/logs", createLogsRoutes(this.deps));
207
+ this.app.route("/api/memory", createMemoryRoutes(this.deps));
208
+ this.app.route("/api/soul", createSoulRoutes(this.deps));
209
+ this.app.route("/api/plugins", createPluginsRoutes(this.deps));
210
+ this.app.route("/api/mcp", createMcpRoutes(this.deps));
211
+ this.app.route("/api/workspace", createWorkspaceRoutes(this.deps));
212
+ this.app.route("/api/tasks", createTasksRoutes(this.deps));
213
+ this.app.route("/api/config", createConfigRoutes(this.deps));
214
+ this.app.route("/api/marketplace", createMarketplaceRoutes(this.deps));
215
+ this.app.route("/api/hooks", createHooksRoutes(this.deps));
216
+ this.app.route("/api/ton-proxy", createTonProxyRoutes(this.deps));
217
+ this.app.post("/api/agent/start", async (c) => {
218
+ const lifecycle = this.deps.lifecycle;
219
+ if (!lifecycle) {
220
+ return c.json({ error: "Agent lifecycle not available" }, 503);
221
+ }
222
+ const state = lifecycle.getState();
223
+ if (state === "running") {
224
+ return c.json({ state: "running" }, 409);
225
+ }
226
+ if (state === "stopping") {
227
+ return c.json({ error: "Agent is currently stopping, please wait" }, 409);
228
+ }
229
+ lifecycle.start().catch((err) => {
230
+ log.error({ err }, "Agent start failed");
231
+ });
232
+ return c.json({ state: "starting" });
233
+ });
234
+ this.app.post("/api/agent/stop", async (c) => {
235
+ const lifecycle = this.deps.lifecycle;
236
+ if (!lifecycle) {
237
+ return c.json({ error: "Agent lifecycle not available" }, 503);
238
+ }
239
+ const state = lifecycle.getState();
240
+ if (state === "stopped") {
241
+ return c.json({ state: "stopped" }, 409);
242
+ }
243
+ if (state === "starting") {
244
+ return c.json({ error: "Agent is currently starting, please wait" }, 409);
245
+ }
246
+ lifecycle.stop().catch((err) => {
247
+ log.error({ err }, "Agent stop failed");
248
+ });
249
+ return c.json({ state: "stopping" });
250
+ });
251
+ this.app.get("/api/agent/status", (c) => {
252
+ const lifecycle = this.deps.lifecycle;
253
+ if (!lifecycle) {
254
+ return c.json({ error: "Agent lifecycle not available" }, 503);
255
+ }
256
+ return c.json({
257
+ state: lifecycle.getState(),
258
+ uptime: lifecycle.getUptime(),
259
+ error: lifecycle.getError() ?? null
260
+ });
261
+ });
262
+ this.app.get("/api/agent/events", (c) => {
263
+ const lifecycle = this.deps.lifecycle;
264
+ if (!lifecycle) {
265
+ return c.json({ error: "Agent lifecycle not available" }, 503);
266
+ }
267
+ return streamSSE(c, async (stream) => {
268
+ let aborted = false;
269
+ stream.onAbort(() => {
270
+ aborted = true;
271
+ });
272
+ const now = Date.now();
273
+ await stream.writeSSE({
274
+ event: "status",
275
+ id: String(now),
276
+ data: JSON.stringify({
277
+ state: lifecycle.getState(),
278
+ error: lifecycle.getError() ?? null,
279
+ timestamp: now
280
+ }),
281
+ retry: 3e3
282
+ });
283
+ const onStateChange = (event) => {
284
+ if (aborted) return;
285
+ void stream.writeSSE({
286
+ event: "status",
287
+ id: String(event.timestamp),
288
+ data: JSON.stringify({
289
+ state: event.state,
290
+ error: event.error ?? null,
291
+ timestamp: event.timestamp
292
+ })
293
+ });
294
+ };
295
+ lifecycle.on("stateChange", onStateChange);
296
+ while (!aborted) {
297
+ await stream.sleep(3e4);
298
+ if (aborted) break;
299
+ await stream.writeSSE({
300
+ event: "ping",
301
+ data: ""
302
+ });
303
+ }
304
+ lifecycle.off("stateChange", onStateChange);
305
+ });
306
+ });
307
+ const webDist = findWebDist();
308
+ if (webDist) {
309
+ const indexHtml = readFileSync(join(webDist, "index.html"), "utf-8");
310
+ const mimeTypes = {
311
+ js: "application/javascript",
312
+ css: "text/css",
313
+ svg: "image/svg+xml",
314
+ png: "image/png",
315
+ jpg: "image/jpeg",
316
+ jpeg: "image/jpeg",
317
+ ico: "image/x-icon",
318
+ json: "application/json",
319
+ woff2: "font/woff2",
320
+ woff: "font/woff"
321
+ };
322
+ this.app.get("*", (c) => {
323
+ const filePath = resolve(join(webDist, c.req.path));
324
+ const rel = relative(webDist, filePath);
325
+ if (rel.startsWith("..") || resolve(filePath) !== filePath) {
326
+ return c.html(indexHtml);
327
+ }
328
+ try {
329
+ const content = readFileSync(filePath);
330
+ const ext = filePath.split(".").pop() || "";
331
+ if (mimeTypes[ext]) {
332
+ const immutable = c.req.path.startsWith("/assets/");
333
+ return c.body(content, 200, {
334
+ "Content-Type": mimeTypes[ext],
335
+ "Cache-Control": immutable ? "public, max-age=31536000, immutable" : "public, max-age=3600"
336
+ });
337
+ }
338
+ } catch {
339
+ }
340
+ return c.html(indexHtml);
341
+ });
342
+ }
343
+ this.app.onError((err, c) => {
344
+ log.error({ err }, "WebUI error");
345
+ return c.json(
346
+ {
347
+ success: false,
348
+ error: err.message || "Internal server error"
349
+ },
350
+ 500
351
+ );
352
+ });
353
+ }
354
+ async start() {
355
+ return new Promise((resolve2, reject) => {
356
+ try {
357
+ logInterceptor.install();
358
+ this.server = serve(
359
+ {
360
+ fetch: this.app.fetch,
361
+ hostname: this.deps.config.host,
362
+ port: this.deps.config.port
363
+ },
364
+ (info) => {
365
+ const url = `http://${info.address}:${info.port}`;
366
+ log.info(`WebUI server running`);
367
+ log.info(`URL: ${url}/auth/exchange?token=${this.authToken}`);
368
+ log.info(`Token: ${maskToken(this.authToken)} (use Bearer header for API access)`);
369
+ resolve2();
370
+ }
371
+ );
372
+ } catch (error) {
373
+ logInterceptor.uninstall();
374
+ reject(error);
375
+ }
376
+ });
377
+ }
378
+ async stop() {
379
+ if (this.server) {
380
+ return new Promise((resolve2) => {
381
+ this.server.closeAllConnections();
382
+ this.server?.close(() => {
383
+ logInterceptor.uninstall();
384
+ log.info("WebUI server stopped");
385
+ resolve2();
386
+ });
387
+ });
388
+ }
389
+ }
390
+ getToken() {
391
+ return this.authToken;
392
+ }
393
+ };
394
+ export {
395
+ WebUIServer
396
+ };
@@ -0,0 +1,217 @@
1
+ import {
2
+ createSetupRoutes
3
+ } from "./chunk-OIMAE24Q.js";
4
+ import "./chunk-WFTC3JJW.js";
5
+ import "./chunk-FUNF6H4W.js";
6
+ import "./chunk-AERHOXGC.js";
7
+ import "./chunk-VFA7QMCZ.js";
8
+ import "./chunk-C4NKJT2Z.js";
9
+ import "./chunk-WTDAICGT.js";
10
+ import "./chunk-6OOHHJ4N.js";
11
+ import "./chunk-XQUHC3JZ.js";
12
+ import "./chunk-R4YSJ4EY.js";
13
+ import {
14
+ TELETON_ROOT
15
+ } from "./chunk-EYWNOHMJ.js";
16
+ import {
17
+ createLogger
18
+ } from "./chunk-NQ6FZKCE.js";
19
+ import "./chunk-3RG5ZIWI.js";
20
+
21
+ // src/webui/setup-server.ts
22
+ import { Hono } from "hono";
23
+ import { serve } from "@hono/node-server";
24
+ import { cors } from "hono/cors";
25
+ import { bodyLimit } from "hono/body-limit";
26
+ import { existsSync, readFileSync } from "fs";
27
+ import { join, dirname, resolve, relative } from "path";
28
+ import { fileURLToPath } from "url";
29
+ import { exec } from "child_process";
30
+ import { platform } from "os";
31
+ import { randomBytes } from "crypto";
32
+ import { readFileSync as readYaml, writeFileSync } from "fs";
33
+ import YAML from "yaml";
34
+ var log = createLogger("Setup");
35
+ function findWebDist() {
36
+ const candidates = [resolve("dist/web"), resolve("web")];
37
+ const __dirname = dirname(fileURLToPath(import.meta.url));
38
+ candidates.push(resolve(__dirname, "web"), resolve(__dirname, "../dist/web"));
39
+ for (const candidate of candidates) {
40
+ if (existsSync(join(candidate, "index.html"))) {
41
+ return candidate;
42
+ }
43
+ }
44
+ return null;
45
+ }
46
+ function autoOpenBrowser(url) {
47
+ const os = platform();
48
+ let cmd;
49
+ if (os === "darwin") {
50
+ cmd = `open "${url}"`;
51
+ } else if (os === "win32") {
52
+ cmd = `start "${url}"`;
53
+ } else {
54
+ cmd = `xdg-open "${url}"`;
55
+ }
56
+ exec(cmd, (err) => {
57
+ if (err) {
58
+ log.info(`Open this URL in your browser: ${url}`);
59
+ }
60
+ });
61
+ }
62
+ var SetupServer = class {
63
+ constructor(port = 7777) {
64
+ this.port = port;
65
+ this.app = new Hono();
66
+ this.launchPromise = new Promise((resolve2) => {
67
+ this.launchResolve = resolve2;
68
+ });
69
+ this.setupMiddleware();
70
+ this.setupRoutes();
71
+ this.setupStaticServing();
72
+ }
73
+ app;
74
+ server = null;
75
+ launchResolve = null;
76
+ launchPromise;
77
+ /** Returns a promise that resolves with the auth token when the user clicks "Start Agent" */
78
+ waitForLaunch() {
79
+ return this.launchPromise;
80
+ }
81
+ setupMiddleware() {
82
+ this.app.use(
83
+ "*",
84
+ cors({
85
+ origin: [
86
+ "http://localhost:5173",
87
+ `http://localhost:${this.port}`,
88
+ "http://127.0.0.1:5173",
89
+ `http://127.0.0.1:${this.port}`
90
+ ],
91
+ credentials: true,
92
+ allowMethods: ["GET", "HEAD", "PUT", "POST", "DELETE", "PATCH"],
93
+ allowHeaders: ["Content-Type"],
94
+ maxAge: 3600
95
+ })
96
+ );
97
+ this.app.use(
98
+ "*",
99
+ bodyLimit({
100
+ maxSize: 2 * 1024 * 1024,
101
+ onError: (c) => c.json({ success: false, error: "Request body too large (max 2MB)" }, 413)
102
+ })
103
+ );
104
+ this.app.use("*", async (c, next) => {
105
+ await next();
106
+ c.res.headers.set("X-Content-Type-Options", "nosniff");
107
+ c.res.headers.set("X-Frame-Options", "DENY");
108
+ c.res.headers.set("Referrer-Policy", "strict-origin-when-cross-origin");
109
+ });
110
+ }
111
+ setupRoutes() {
112
+ this.app.get("/health", (c) => c.json({ status: "ok" }));
113
+ this.app.route("/api/setup", createSetupRoutes());
114
+ this.app.get(
115
+ "/auth/check",
116
+ (c) => c.json({ success: true, data: { authenticated: false, setup: true } })
117
+ );
118
+ this.app.post("/api/setup/launch", async (c) => {
119
+ try {
120
+ const token = randomBytes(32).toString("hex");
121
+ const configPath = join(TELETON_ROOT, "config.yaml");
122
+ const raw = readYaml(configPath, "utf-8");
123
+ const config = YAML.parse(raw);
124
+ config.webui = { ...config.webui || {}, enabled: true, auth_token: token };
125
+ writeFileSync(configPath, YAML.stringify(config), { encoding: "utf-8", mode: 384 });
126
+ log.info("Launch requested \u2014 auth token generated");
127
+ const resolve2 = this.launchResolve;
128
+ this.launchResolve = null;
129
+ if (resolve2) {
130
+ setTimeout(() => resolve2(token), 500);
131
+ }
132
+ return c.json({ success: true, data: { token } });
133
+ } catch (err) {
134
+ return c.json(
135
+ { success: false, error: err instanceof Error ? err.message : String(err) },
136
+ 500
137
+ );
138
+ }
139
+ });
140
+ this.app.onError((err, c) => {
141
+ log.error({ err }, "Setup server error");
142
+ return c.json({ success: false, error: err.message || "Internal server error" }, 500);
143
+ });
144
+ }
145
+ setupStaticServing() {
146
+ const webDist = findWebDist();
147
+ if (!webDist) return;
148
+ const indexHtml = readFileSync(join(webDist, "index.html"), "utf-8");
149
+ const mimeTypes = {
150
+ js: "application/javascript",
151
+ css: "text/css",
152
+ svg: "image/svg+xml",
153
+ png: "image/png",
154
+ jpg: "image/jpeg",
155
+ jpeg: "image/jpeg",
156
+ ico: "image/x-icon",
157
+ json: "application/json",
158
+ woff2: "font/woff2",
159
+ woff: "font/woff"
160
+ };
161
+ this.app.get("*", (c) => {
162
+ const filePath = resolve(join(webDist, c.req.path));
163
+ const rel = relative(webDist, filePath);
164
+ if (rel.startsWith("..") || resolve(filePath) !== filePath) {
165
+ return c.html(indexHtml);
166
+ }
167
+ try {
168
+ const content = readFileSync(filePath);
169
+ const ext = filePath.split(".").pop() || "";
170
+ if (mimeTypes[ext]) {
171
+ const immutable = c.req.path.startsWith("/assets/");
172
+ return c.body(content, 200, {
173
+ "Content-Type": mimeTypes[ext],
174
+ "Cache-Control": immutable ? "public, max-age=31536000, immutable" : "public, max-age=3600"
175
+ });
176
+ }
177
+ } catch {
178
+ }
179
+ return c.html(indexHtml);
180
+ });
181
+ }
182
+ async start() {
183
+ return new Promise((resolve2, reject) => {
184
+ try {
185
+ this.server = serve(
186
+ {
187
+ fetch: this.app.fetch,
188
+ hostname: "127.0.0.1",
189
+ port: this.port
190
+ },
191
+ () => {
192
+ const url = `http://localhost:${this.port}/setup`;
193
+ log.info(`Setup wizard: ${url}`);
194
+ autoOpenBrowser(url);
195
+ resolve2();
196
+ }
197
+ );
198
+ } catch (error) {
199
+ reject(error);
200
+ }
201
+ });
202
+ }
203
+ async stop() {
204
+ if (this.server) {
205
+ return new Promise((resolve2) => {
206
+ this.server.closeAllConnections();
207
+ this.server?.close(() => {
208
+ log.info("Setup server stopped");
209
+ resolve2();
210
+ });
211
+ });
212
+ }
213
+ }
214
+ };
215
+ export {
216
+ SetupServer
217
+ };
@@ -9,15 +9,16 @@ import {
9
9
  saveSessionStore,
10
10
  shouldResetSession,
11
11
  updateSession
12
- } from "./chunk-KVXV7EF7.js";
13
- import "./chunk-7U7BOHCL.js";
14
- import "./chunk-3S4GGLLR.js";
12
+ } from "./chunk-XDZDOKIF.js";
13
+ import "./chunk-GHMXWAXI.js";
14
+ import "./chunk-35MX4ZUI.js";
15
15
  import "./chunk-VFA7QMCZ.js";
16
- import "./chunk-UP55PXFH.js";
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
- import "./chunk-RCMD3U65.js";
21
+ import "./chunk-NQ6FZKCE.js";
21
22
  import "./chunk-4L66JHQE.js";
22
23
  import "./chunk-3RG5ZIWI.js";
23
24
  export {
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  MAX_DEPENDENTS_PER_TASK
3
- } from "./chunk-UP55PXFH.js";
3
+ } from "./chunk-C4NKJT2Z.js";
4
4
  import {
5
5
  BATCH_TRIGGER_DELAY_MS
6
6
  } from "./chunk-R4YSJ4EY.js";
7
7
  import {
8
8
  createLogger
9
- } from "./chunk-RCMD3U65.js";
9
+ } from "./chunk-NQ6FZKCE.js";
10
10
  import "./chunk-3RG5ZIWI.js";
11
11
 
12
12
  // src/telegram/task-dependency-resolver.ts
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  getErrorMessage
3
- } from "./chunk-XBE4JB7C.js";
3
+ } from "./chunk-3UFPFWYP.js";
4
4
  import {
5
5
  MAX_JSON_FIELD_CHARS,
6
6
  MAX_TOTAL_PROMPT_CHARS,
7
7
  SECONDS_PER_DAY,
8
8
  SECONDS_PER_HOUR
9
- } from "./chunk-UP55PXFH.js";
9
+ } from "./chunk-C4NKJT2Z.js";
10
10
  import "./chunk-3RG5ZIWI.js";
11
11
 
12
12
  // src/telegram/task-executor.ts
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createLogger
3
- } from "./chunk-RCMD3U65.js";
3
+ } from "./chunk-NQ6FZKCE.js";
4
4
  import "./chunk-3RG5ZIWI.js";
5
5
 
6
6
  // src/cocoon/tool-adapter.ts
@@ -1,18 +1,19 @@
1
1
  import {
2
2
  serializeEmbedding
3
- } from "./chunk-3S4GGLLR.js";
3
+ } from "./chunk-35MX4ZUI.js";
4
4
  import "./chunk-VFA7QMCZ.js";
5
5
  import {
6
6
  TOOL_RAG_KEYWORD_WEIGHT,
7
7
  TOOL_RAG_MIN_SCORE,
8
8
  TOOL_RAG_VECTOR_WEIGHT
9
- } from "./chunk-UP55PXFH.js";
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
15
- } from "./chunk-RCMD3U65.js";
16
+ } from "./chunk-NQ6FZKCE.js";
16
17
  import "./chunk-3RG5ZIWI.js";
17
18
 
18
19
  // src/agent/tools/tool-index.ts