teleton 0.6.0 → 0.7.0

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 (39) hide show
  1. package/README.md +26 -26
  2. package/dist/{chunk-D5I7GBV7.js → chunk-FNV5FF35.js} +22 -13
  3. package/dist/chunk-LRCPA7SC.js +149 -0
  4. package/dist/{chunk-ADCMUNYU.js → chunk-N3F7E7DR.js} +58 -53
  5. package/dist/chunk-ND2X5FWB.js +368 -0
  6. package/dist/chunk-NERLQY2H.js +421 -0
  7. package/dist/{chunk-YBA6IBGT.js → chunk-OCLG5GKI.js} +24 -24
  8. package/dist/{chunk-6L6KGATM.js → chunk-OGIG552S.js} +1397 -1688
  9. package/dist/chunk-RCMD3U65.js +141 -0
  10. package/dist/{chunk-4IPJ25HE.js → chunk-TCD4NZDA.js} +1045 -658
  11. package/dist/{chunk-ECSCVEQQ.js → chunk-UCN6TI25.js} +7 -3
  12. package/dist/{chunk-WL2Q3VRD.js → chunk-UDD7FYOU.js} +12 -4
  13. package/dist/chunk-VAUJSSD3.js +20 -0
  14. package/dist/chunk-XBE4JB7C.js +8 -0
  15. package/dist/{chunk-GDCODBNO.js → chunk-XBKSS6DM.js} +2 -16
  16. package/dist/cli/index.js +878 -433
  17. package/dist/client-3VWE7NC4.js +29 -0
  18. package/dist/{get-my-gifts-KVULMBJ3.js → get-my-gifts-RI7FAXAL.js} +3 -1
  19. package/dist/index.js +17 -11
  20. package/dist/{memory-TVDOGQXS.js → memory-RD7ZSTRV.js} +7 -5
  21. package/dist/{migrate-QIEMPOMT.js → migrate-GO4NOBT7.js} +14 -9
  22. package/dist/{server-RSWVCVY3.js → server-OWVEZTR3.js} +81 -84
  23. package/dist/setup-server-C7ZTPHD5.js +934 -0
  24. package/dist/{task-dependency-resolver-72DLY2HV.js → task-dependency-resolver-WKZWJLLM.js} +19 -15
  25. package/dist/{task-executor-VXB6DAV2.js → task-executor-PD3H4MLO.js} +4 -1
  26. package/dist/tool-adapter-Y3TCEQOC.js +145 -0
  27. package/dist/{tool-index-DKI2ZNOU.js → tool-index-MIVK3D7H.js} +14 -9
  28. package/dist/{transcript-7V4UNID4.js → transcript-UDJZP6NK.js} +2 -1
  29. package/dist/web/assets/complete-fZLnb5Ot.js +1 -0
  30. package/dist/web/assets/index-B_FcaX5D.css +1 -0
  31. package/dist/web/assets/index-CbeAP4_n.js +67 -0
  32. package/dist/web/assets/index.es-oXiZF7Hc.js +11 -0
  33. package/dist/web/assets/login-telegram-BP7CJDmx.js +1 -0
  34. package/dist/web/assets/run-DOrDowjK.js +1 -0
  35. package/dist/web/index.html +2 -2
  36. package/package.json +7 -3
  37. package/dist/chunk-2QUJLHCZ.js +0 -362
  38. package/dist/web/assets/index-BNhrx9S1.js +0 -67
  39. package/dist/web/assets/index-CqrrRLOh.css +0 -1
@@ -0,0 +1,141 @@
1
+ // src/utils/logger.ts
2
+ import pino from "pino";
3
+ import { Writable } from "stream";
4
+ var listeners = /* @__PURE__ */ new Set();
5
+ function addLogListener(fn) {
6
+ listeners.add(fn);
7
+ return () => listeners.delete(fn);
8
+ }
9
+ function clearLogListeners() {
10
+ listeners.clear();
11
+ }
12
+ var LEVEL_MAP = {
13
+ 10: "log",
14
+ // trace → log
15
+ 20: "log",
16
+ // debug → log
17
+ 30: "log",
18
+ // info → log
19
+ 40: "warn",
20
+ // warn → warn
21
+ 50: "error",
22
+ // error → error
23
+ 60: "error"
24
+ // fatal → error
25
+ };
26
+ var WebUILogStream = class extends Writable {
27
+ _write(chunk, _encoding, callback) {
28
+ if (listeners.size === 0) {
29
+ callback();
30
+ return;
31
+ }
32
+ try {
33
+ const obj = JSON.parse(chunk.toString());
34
+ const entry = {
35
+ level: LEVEL_MAP[obj.level] ?? "log",
36
+ message: obj.msg ?? "",
37
+ timestamp: obj.time ?? Date.now()
38
+ };
39
+ for (const fn of listeners) {
40
+ try {
41
+ fn(entry);
42
+ } catch {
43
+ }
44
+ }
45
+ } catch {
46
+ }
47
+ callback();
48
+ }
49
+ };
50
+ var VALID_LEVELS = ["fatal", "error", "warn", "info", "debug", "trace"];
51
+ function isValidLevel(s) {
52
+ return VALID_LEVELS.includes(s);
53
+ }
54
+ function resolveLevel() {
55
+ const explicit = process.env.TELETON_LOG_LEVEL?.toLowerCase();
56
+ if (explicit && isValidLevel(explicit)) {
57
+ return explicit;
58
+ }
59
+ if (process.env.TELETON_LOG === "verbose") {
60
+ return "debug";
61
+ }
62
+ return "info";
63
+ }
64
+ var webUIStream = new WebUILogStream();
65
+ var usePretty = process.env.TELETON_LOG_PRETTY !== "false";
66
+ var stdoutStream = usePretty ? pino.transport({
67
+ target: "pino-pretty",
68
+ options: {
69
+ colorize: true,
70
+ translateTime: "HH:MM:ss",
71
+ ignore: "pid,hostname,module",
72
+ messageFormat: "{if module}[{module}] {end}{msg}"
73
+ }
74
+ }) : pino.destination(1);
75
+ var initialLevel = resolveLevel();
76
+ var multiStream = pino.multistream([
77
+ { stream: stdoutStream, level: initialLevel },
78
+ { stream: webUIStream, level: "trace" }
79
+ // WebUI gets everything
80
+ ]);
81
+ var rootLogger = pino(
82
+ {
83
+ level: initialLevel,
84
+ timestamp: pino.stdTimeFunctions.isoTime,
85
+ base: null,
86
+ // no pid/hostname noise
87
+ redact: {
88
+ paths: [
89
+ "apiKey",
90
+ "api_key",
91
+ "password",
92
+ "secret",
93
+ "token",
94
+ "mnemonic",
95
+ "*.apiKey",
96
+ "*.api_key",
97
+ "*.password",
98
+ "*.secret",
99
+ "*.token",
100
+ "*.mnemonic"
101
+ ],
102
+ censor: "[REDACTED]"
103
+ }
104
+ },
105
+ multiStream
106
+ );
107
+ function createLogger(module) {
108
+ return rootLogger.child({ module });
109
+ }
110
+ function initLoggerFromConfig(logging) {
111
+ if (!process.env.TELETON_LOG_LEVEL && !process.env.TELETON_LOG) {
112
+ const level = logging.level?.toLowerCase();
113
+ if (level && isValidLevel(level)) {
114
+ setLogLevel(level);
115
+ }
116
+ }
117
+ }
118
+ function setLogLevel(level) {
119
+ rootLogger.level = level;
120
+ const streams = multiStream.streams;
121
+ if (Array.isArray(streams) && streams[0]) {
122
+ streams[0].level = pino.levels.values[level] ?? 30;
123
+ }
124
+ _verbose = level === "debug" || level === "trace";
125
+ }
126
+ var _verbose = rootLogger.isLevelEnabled("debug");
127
+ function setVerbose(v) {
128
+ setLogLevel(v ? "debug" : "info");
129
+ }
130
+ function isVerbose() {
131
+ return _verbose;
132
+ }
133
+
134
+ export {
135
+ addLogListener,
136
+ clearLogListeners,
137
+ createLogger,
138
+ initLoggerFromConfig,
139
+ setVerbose,
140
+ isVerbose
141
+ };