teleton 0.8.3 → 0.8.5
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 +241 -301
- package/dist/{bootstrap-DDFVEMYI.js → bootstrap-SPDT3XBQ.js} +5 -7
- package/dist/{chunk-GHMXWAXI.js → chunk-2MZP75SH.js} +72 -202
- package/dist/chunk-35X3V6OW.js +139 -0
- package/dist/{chunk-LVTKJQ7O.js → chunk-4KURCUWD.js} +1 -1
- package/dist/{chunk-XDZDOKIF.js → chunk-5K4YDCVU.js} +1 -1
- package/dist/{chunk-7MWKT67G.js → chunk-6U6VA2OT.js} +520 -2187
- package/dist/{chunk-OIMAE24Q.js → chunk-7ZXUUDQQ.js} +18 -7
- package/dist/{chunk-AERHOXGC.js → chunk-FSL2MOYK.js} +236 -93
- package/dist/{chunk-LC4TV3KL.js → chunk-GUX6ZFVF.js} +1 -1
- package/dist/{chunk-CUE4UZXR.js → chunk-KYSAHDYE.js} +2 -2
- package/dist/{chunk-C4NKJT2Z.js → chunk-L3LPVF4Z.js} +1 -1
- package/dist/{chunk-EYWNOHMJ.js → chunk-L653KKCR.js} +1 -0
- package/dist/{chunk-ALKAAG4O.js → chunk-LD24DWWE.js} +4 -4
- package/dist/{chunk-33Z47EXI.js → chunk-LM6AL6LN.js} +2417 -867
- package/dist/chunk-M6M4DCDU.js +942 -0
- package/dist/{chunk-35MX4ZUI.js → chunk-PK3TVFBT.js} +2 -2
- package/dist/{chunk-2ERTYRHA.js → chunk-Z63KUQX4.js} +37 -13
- package/dist/cli/index.js +35 -25
- package/dist/{client-5KD25NOP.js → client-G62EZT6U.js} +3 -3
- package/dist/harden-permissions-6BLHRCQJ.js +100 -0
- package/dist/index.js +14 -14
- package/dist/{local-IHKJFQJS.js → local-HQ3UJ7KR.js} +2 -2
- package/dist/{memory-QMJRM3XJ.js → memory-BJH724PQ.js} +6 -5
- package/dist/{memory-hook-VUNWZ3NY.js → memory-hook-LUAKTXU5.js} +5 -5
- package/dist/{migrate-5VBAP52B.js → migrate-C4LBLOZH.js} +6 -5
- package/dist/{paths-XA2RJH4S.js → paths-WMVV7ZAJ.js} +1 -1
- package/dist/{server-JF6FX772.js → server-4J56HS62.js} +8 -15
- package/dist/{server-N4T7E25M.js → server-I6TYJ36S.js} +7 -15
- package/dist/{setup-server-IX3BFPPH.js → setup-server-VJ3MGUSM.js} +16 -17
- package/dist/{store-BY7S6IFN.js → store-2IGAMTES.js} +7 -6
- package/dist/{task-dependency-resolver-L6UUMTHK.js → task-dependency-resolver-CQ432Z7J.js} +1 -1
- package/dist/{task-executor-XBNJLUCS.js → task-executor-JELRREUV.js} +1 -1
- package/dist/{tool-index-FTERJSZK.js → tool-index-XPCMWBYY.js} +4 -4
- package/dist/{transcript-IM7G25OS.js → transcript-OEO3HA4Z.js} +2 -2
- package/dist/web/assets/{index-BfYCdwLI.js → index-Dn5ZH1Y6.js} +13 -13
- package/dist/web/assets/{index.es-DitvF-9H.js → index.es-eSR4Qv6s.js} +1 -1
- package/dist/web/index.html +1 -1
- package/package.json +2 -6
- package/src/templates/HEARTBEAT.md +5 -0
- package/dist/chunk-AEHTQI3H.js +0 -142
- package/dist/chunk-FUNF6H4W.js +0 -251
|
@@ -5,18 +5,20 @@ import {
|
|
|
5
5
|
generateWallet,
|
|
6
6
|
getWalletAddress,
|
|
7
7
|
importWallet,
|
|
8
|
+
readRawConfig,
|
|
8
9
|
saveWallet,
|
|
9
|
-
walletExists
|
|
10
|
-
|
|
10
|
+
walletExists,
|
|
11
|
+
writeRawConfig
|
|
12
|
+
} from "./chunk-M6M4DCDU.js";
|
|
11
13
|
import {
|
|
12
14
|
ConfigSchema,
|
|
13
15
|
DealsConfigSchema,
|
|
14
16
|
ensureWorkspace,
|
|
15
17
|
isNewWorkspace
|
|
16
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-FSL2MOYK.js";
|
|
17
19
|
import {
|
|
18
20
|
TELEGRAM_MAX_MESSAGE_LENGTH
|
|
19
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-L3LPVF4Z.js";
|
|
20
22
|
import {
|
|
21
23
|
getClaudeCodeApiKey,
|
|
22
24
|
isClaudeCodeTokenValid
|
|
@@ -31,7 +33,7 @@ import {
|
|
|
31
33
|
} from "./chunk-XQUHC3JZ.js";
|
|
32
34
|
import {
|
|
33
35
|
TELETON_ROOT
|
|
34
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-L653KKCR.js";
|
|
35
37
|
import {
|
|
36
38
|
createLogger
|
|
37
39
|
} from "./chunk-NQ6FZKCE.js";
|
|
@@ -380,7 +382,16 @@ var TelegramAuthManager = class {
|
|
|
380
382
|
mkdirSync(dir, { recursive: true });
|
|
381
383
|
}
|
|
382
384
|
writeFileSync(sessionPath, sessionString, { mode: 384 });
|
|
383
|
-
|
|
385
|
+
const configPath = join(TELETON_ROOT, "config.yaml");
|
|
386
|
+
const raw = readRawConfig(configPath);
|
|
387
|
+
raw.telegram = raw.telegram ?? {};
|
|
388
|
+
raw.telegram.api_id = session.apiId;
|
|
389
|
+
raw.telegram.api_hash = session.apiHash;
|
|
390
|
+
if (session.type === "phone") {
|
|
391
|
+
raw.telegram.phone = session.phone;
|
|
392
|
+
}
|
|
393
|
+
writeRawConfig(raw, configPath);
|
|
394
|
+
log.info("Telegram session and credentials saved");
|
|
384
395
|
}
|
|
385
396
|
};
|
|
386
397
|
|
|
@@ -750,7 +761,7 @@ function createSetupRoutes(options) {
|
|
|
750
761
|
});
|
|
751
762
|
app.post("/embeddings/warmup", async (c) => {
|
|
752
763
|
try {
|
|
753
|
-
const { LocalEmbeddingProvider } = await import("./local-
|
|
764
|
+
const { LocalEmbeddingProvider } = await import("./local-HQ3UJ7KR.js");
|
|
754
765
|
const provider = new LocalEmbeddingProvider({});
|
|
755
766
|
const success = await provider.warmup();
|
|
756
767
|
return c.json({
|
|
@@ -1,106 +1,23 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TELEGRAM_MAX_MESSAGE_LENGTH
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-L3LPVF4Z.js";
|
|
4
|
+
import {
|
|
5
|
+
getProviderMetadata
|
|
6
|
+
} from "./chunk-6OOHHJ4N.js";
|
|
4
7
|
import {
|
|
5
8
|
TELETON_ROOT,
|
|
6
9
|
WORKSPACE_PATHS,
|
|
7
10
|
WORKSPACE_ROOT
|
|
8
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-L653KKCR.js";
|
|
9
12
|
import {
|
|
10
13
|
createLogger
|
|
11
14
|
} from "./chunk-NQ6FZKCE.js";
|
|
12
15
|
|
|
13
|
-
// src/
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
function findPackageRoot() {
|
|
19
|
-
let dir = dirname(fileURLToPath(import.meta.url));
|
|
20
|
-
for (let i = 0; i < 10; i++) {
|
|
21
|
-
if (existsSync(join(dir, "package.json"))) return dir;
|
|
22
|
-
dir = dirname(dir);
|
|
23
|
-
}
|
|
24
|
-
return process.cwd();
|
|
25
|
-
}
|
|
26
|
-
var TEMPLATES_DIR = join(findPackageRoot(), "src", "templates");
|
|
27
|
-
async function ensureWorkspace(config) {
|
|
28
|
-
const silent = config?.silent ?? false;
|
|
29
|
-
if (!existsSync(TELETON_ROOT)) {
|
|
30
|
-
mkdirSync(TELETON_ROOT, { recursive: true });
|
|
31
|
-
if (!silent) log.info(`Created Teleton root at ${TELETON_ROOT}`);
|
|
32
|
-
}
|
|
33
|
-
if (!existsSync(WORKSPACE_ROOT)) {
|
|
34
|
-
mkdirSync(WORKSPACE_ROOT, { recursive: true });
|
|
35
|
-
if (!silent) log.info(`Created workspace at ${WORKSPACE_ROOT}`);
|
|
36
|
-
}
|
|
37
|
-
const directories = [
|
|
38
|
-
WORKSPACE_PATHS.MEMORY_DIR,
|
|
39
|
-
WORKSPACE_PATHS.DOWNLOADS_DIR,
|
|
40
|
-
WORKSPACE_PATHS.UPLOADS_DIR,
|
|
41
|
-
WORKSPACE_PATHS.TEMP_DIR,
|
|
42
|
-
WORKSPACE_PATHS.MEMES_DIR
|
|
43
|
-
];
|
|
44
|
-
for (const dir of directories) {
|
|
45
|
-
if (!existsSync(dir)) {
|
|
46
|
-
mkdirSync(dir, { recursive: true });
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
const workspace = {
|
|
50
|
-
root: TELETON_ROOT,
|
|
51
|
-
workspace: WORKSPACE_ROOT,
|
|
52
|
-
// Workspace files
|
|
53
|
-
soulPath: WORKSPACE_PATHS.SOUL,
|
|
54
|
-
memoryPath: WORKSPACE_PATHS.MEMORY,
|
|
55
|
-
identityPath: WORKSPACE_PATHS.IDENTITY,
|
|
56
|
-
userPath: WORKSPACE_PATHS.USER,
|
|
57
|
-
strategyPath: WORKSPACE_PATHS.STRATEGY,
|
|
58
|
-
securityPath: WORKSPACE_PATHS.SECURITY,
|
|
59
|
-
// Workspace directories
|
|
60
|
-
memoryDir: WORKSPACE_PATHS.MEMORY_DIR,
|
|
61
|
-
downloadsDir: WORKSPACE_PATHS.DOWNLOADS_DIR,
|
|
62
|
-
uploadsDir: WORKSPACE_PATHS.UPLOADS_DIR,
|
|
63
|
-
tempDir: WORKSPACE_PATHS.TEMP_DIR,
|
|
64
|
-
memesDir: WORKSPACE_PATHS.MEMES_DIR,
|
|
65
|
-
// Protected files (outside workspace)
|
|
66
|
-
sessionPath: join(TELETON_ROOT, "telegram_session.txt"),
|
|
67
|
-
configPath: join(TELETON_ROOT, "config.yaml"),
|
|
68
|
-
walletPath: join(TELETON_ROOT, "wallet.json")
|
|
69
|
-
};
|
|
70
|
-
if (config?.ensureTemplates) {
|
|
71
|
-
await bootstrapTemplates(workspace, silent);
|
|
72
|
-
}
|
|
73
|
-
return workspace;
|
|
74
|
-
}
|
|
75
|
-
async function bootstrapTemplates(workspace, silent = false) {
|
|
76
|
-
const templates = [
|
|
77
|
-
{ name: "SOUL.md", path: workspace.soulPath },
|
|
78
|
-
{ name: "MEMORY.md", path: workspace.memoryPath },
|
|
79
|
-
{ name: "IDENTITY.md", path: workspace.identityPath },
|
|
80
|
-
{ name: "USER.md", path: workspace.userPath },
|
|
81
|
-
{ name: "SECURITY.md", path: workspace.securityPath },
|
|
82
|
-
{ name: "STRATEGY.md", path: workspace.strategyPath }
|
|
83
|
-
];
|
|
84
|
-
for (const template of templates) {
|
|
85
|
-
if (!existsSync(template.path)) {
|
|
86
|
-
const templateSource = join(TEMPLATES_DIR, template.name);
|
|
87
|
-
if (existsSync(templateSource)) {
|
|
88
|
-
copyFileSync(templateSource, template.path);
|
|
89
|
-
if (!silent) log.info(`Created ${template.name}`);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
function isNewWorkspace(workspace) {
|
|
95
|
-
return !existsSync(workspace.configPath);
|
|
96
|
-
}
|
|
97
|
-
function loadTemplate(name) {
|
|
98
|
-
const templatePath = join(TEMPLATES_DIR, name);
|
|
99
|
-
if (!existsSync(templatePath)) {
|
|
100
|
-
throw new Error(`Template ${name} not found at ${templatePath}`);
|
|
101
|
-
}
|
|
102
|
-
return readFileSync(templatePath, "utf-8");
|
|
103
|
-
}
|
|
16
|
+
// src/config/loader.ts
|
|
17
|
+
import { readFileSync, existsSync, writeFileSync, mkdirSync } from "fs";
|
|
18
|
+
import { parse, stringify } from "yaml";
|
|
19
|
+
import { homedir } from "os";
|
|
20
|
+
import { dirname, join } from "path";
|
|
104
21
|
|
|
105
22
|
// src/config/schema.ts
|
|
106
23
|
import { z } from "zod";
|
|
@@ -268,6 +185,15 @@ var _CapabilitiesObject = z.object({
|
|
|
268
185
|
exec: _ExecObject.default(_ExecObject.parse({}))
|
|
269
186
|
});
|
|
270
187
|
var CapabilitiesConfigSchema = _CapabilitiesObject.default(_CapabilitiesObject.parse({}));
|
|
188
|
+
var _HeartbeatObject = z.object({
|
|
189
|
+
enabled: z.boolean().default(true).describe("Enable periodic heartbeat timer"),
|
|
190
|
+
interval_ms: z.number().min(6e4).default(18e5).describe("Heartbeat interval in milliseconds (min 60s, default 30min)"),
|
|
191
|
+
prompt: z.string().default(
|
|
192
|
+
"Read HEARTBEAT.md if it exists. Follow it strictly. If nothing needs attention, reply NO_ACTION."
|
|
193
|
+
).describe("Prompt sent to agent on each heartbeat tick"),
|
|
194
|
+
self_configurable: z.boolean().default(false).describe("Allow agent to modify heartbeat config via config_set")
|
|
195
|
+
});
|
|
196
|
+
var HeartbeatConfigSchema = _HeartbeatObject.default(_HeartbeatObject.parse({}));
|
|
271
197
|
var ConfigSchema = z.object({
|
|
272
198
|
meta: MetaConfigSchema.default(MetaConfigSchema.parse({})),
|
|
273
199
|
agent: AgentConfigSchema,
|
|
@@ -282,6 +208,7 @@ var ConfigSchema = z.object({
|
|
|
282
208
|
capabilities: CapabilitiesConfigSchema,
|
|
283
209
|
api: ApiConfigSchema.optional(),
|
|
284
210
|
ton_proxy: TonProxyConfigSchema,
|
|
211
|
+
heartbeat: HeartbeatConfigSchema,
|
|
285
212
|
mcp: McpConfigSchema,
|
|
286
213
|
plugins: z.record(z.string(), z.unknown()).default({}).describe("Per-plugin config (key = plugin name with underscores)"),
|
|
287
214
|
cocoon: z.object({
|
|
@@ -292,9 +219,225 @@ var ConfigSchema = z.object({
|
|
|
292
219
|
tavily_api_key: z.string().optional().describe("Tavily API key for web search & extract (free at https://tavily.com)")
|
|
293
220
|
});
|
|
294
221
|
|
|
222
|
+
// src/config/loader.ts
|
|
223
|
+
var log = createLogger("Config");
|
|
224
|
+
var DEFAULT_CONFIG_PATH = join(TELETON_ROOT, "config.yaml");
|
|
225
|
+
function expandPath(path) {
|
|
226
|
+
if (path.startsWith("~")) {
|
|
227
|
+
return join(homedir(), path.slice(1));
|
|
228
|
+
}
|
|
229
|
+
return path;
|
|
230
|
+
}
|
|
231
|
+
function loadConfig(configPath = DEFAULT_CONFIG_PATH) {
|
|
232
|
+
const fullPath = expandPath(configPath);
|
|
233
|
+
if (!existsSync(fullPath)) {
|
|
234
|
+
throw new Error(`Config file not found: ${fullPath}
|
|
235
|
+
Run 'teleton setup' to create one.`);
|
|
236
|
+
}
|
|
237
|
+
let content;
|
|
238
|
+
try {
|
|
239
|
+
content = readFileSync(fullPath, "utf-8");
|
|
240
|
+
} catch (error) {
|
|
241
|
+
throw new Error(`Cannot read config file ${fullPath}: ${error.message}`);
|
|
242
|
+
}
|
|
243
|
+
let raw;
|
|
244
|
+
try {
|
|
245
|
+
raw = parse(content);
|
|
246
|
+
} catch (error) {
|
|
247
|
+
throw new Error(`Invalid YAML in ${fullPath}: ${error.message}`);
|
|
248
|
+
}
|
|
249
|
+
if (raw && typeof raw === "object" && "market" in raw) {
|
|
250
|
+
log.warn("config.market is deprecated and ignored. Use market-api plugin instead.");
|
|
251
|
+
delete raw.market;
|
|
252
|
+
}
|
|
253
|
+
const result = ConfigSchema.safeParse(raw);
|
|
254
|
+
if (!result.success) {
|
|
255
|
+
throw new Error(`Invalid config: ${result.error.message}`);
|
|
256
|
+
}
|
|
257
|
+
const config = result.data;
|
|
258
|
+
const provider = config.agent.provider;
|
|
259
|
+
if (provider !== "anthropic" && provider !== "claude-code" && !raw.agent?.model) {
|
|
260
|
+
const meta = getProviderMetadata(provider);
|
|
261
|
+
config.agent.model = meta.defaultModel;
|
|
262
|
+
}
|
|
263
|
+
config.telegram.session_path = expandPath(config.telegram.session_path);
|
|
264
|
+
config.storage.sessions_file = expandPath(config.storage.sessions_file);
|
|
265
|
+
config.storage.memory_file = expandPath(config.storage.memory_file);
|
|
266
|
+
if (process.env.TELETON_API_KEY) {
|
|
267
|
+
config.agent.api_key = process.env.TELETON_API_KEY;
|
|
268
|
+
}
|
|
269
|
+
if (process.env.TELETON_TG_API_ID) {
|
|
270
|
+
const apiId = parseInt(process.env.TELETON_TG_API_ID, 10);
|
|
271
|
+
if (isNaN(apiId)) {
|
|
272
|
+
throw new Error(
|
|
273
|
+
`Invalid TELETON_TG_API_ID environment variable: "${process.env.TELETON_TG_API_ID}" is not a valid integer`
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
config.telegram.api_id = apiId;
|
|
277
|
+
}
|
|
278
|
+
if (process.env.TELETON_TG_API_HASH) {
|
|
279
|
+
config.telegram.api_hash = process.env.TELETON_TG_API_HASH;
|
|
280
|
+
}
|
|
281
|
+
if (process.env.TELETON_TG_PHONE) {
|
|
282
|
+
config.telegram.phone = process.env.TELETON_TG_PHONE;
|
|
283
|
+
}
|
|
284
|
+
if (process.env.TELETON_WEBUI_ENABLED) {
|
|
285
|
+
config.webui.enabled = process.env.TELETON_WEBUI_ENABLED === "true";
|
|
286
|
+
}
|
|
287
|
+
if (process.env.TELETON_WEBUI_PORT) {
|
|
288
|
+
const port = parseInt(process.env.TELETON_WEBUI_PORT, 10);
|
|
289
|
+
if (!isNaN(port) && port >= 1024 && port <= 65535) {
|
|
290
|
+
config.webui.port = port;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
if (process.env.TELETON_WEBUI_HOST) {
|
|
294
|
+
config.webui.host = process.env.TELETON_WEBUI_HOST;
|
|
295
|
+
if (!["127.0.0.1", "localhost", "::1"].includes(config.webui.host)) {
|
|
296
|
+
log.warn(
|
|
297
|
+
{ host: config.webui.host },
|
|
298
|
+
"WebUI bound to non-loopback address \u2014 ensure auth_token is set"
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
if (process.env.TELETON_API_ENABLED) {
|
|
303
|
+
if (!config.api) config.api = { enabled: false, port: 7778, key_hash: "", allowed_ips: [] };
|
|
304
|
+
config.api.enabled = process.env.TELETON_API_ENABLED === "true";
|
|
305
|
+
}
|
|
306
|
+
if (process.env.TELETON_API_PORT) {
|
|
307
|
+
const port = parseInt(process.env.TELETON_API_PORT, 10);
|
|
308
|
+
if (!isNaN(port) && port >= 1024 && port <= 65535) {
|
|
309
|
+
if (!config.api) config.api = { enabled: false, port: 7778, key_hash: "", allowed_ips: [] };
|
|
310
|
+
config.api.port = port;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
if (process.env.TELETON_BASE_URL) {
|
|
314
|
+
try {
|
|
315
|
+
new URL(process.env.TELETON_BASE_URL);
|
|
316
|
+
config.agent.base_url = process.env.TELETON_BASE_URL;
|
|
317
|
+
} catch {
|
|
318
|
+
throw new Error(
|
|
319
|
+
`Invalid TELETON_BASE_URL: "${process.env.TELETON_BASE_URL}" is not a valid URL`
|
|
320
|
+
);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
if (process.env.TELETON_TAVILY_API_KEY) {
|
|
324
|
+
config.tavily_api_key = process.env.TELETON_TAVILY_API_KEY;
|
|
325
|
+
}
|
|
326
|
+
if (process.env.TELETON_TONAPI_KEY) {
|
|
327
|
+
config.tonapi_key = process.env.TELETON_TONAPI_KEY;
|
|
328
|
+
}
|
|
329
|
+
if (process.env.TELETON_TONCENTER_API_KEY) {
|
|
330
|
+
config.toncenter_api_key = process.env.TELETON_TONCENTER_API_KEY;
|
|
331
|
+
}
|
|
332
|
+
return config;
|
|
333
|
+
}
|
|
334
|
+
function configExists(configPath = DEFAULT_CONFIG_PATH) {
|
|
335
|
+
return existsSync(expandPath(configPath));
|
|
336
|
+
}
|
|
337
|
+
function getDefaultConfigPath() {
|
|
338
|
+
return DEFAULT_CONFIG_PATH;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
// src/workspace/manager.ts
|
|
342
|
+
import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2, copyFileSync } from "fs";
|
|
343
|
+
import { join as join2, dirname as dirname2 } from "path";
|
|
344
|
+
import { fileURLToPath } from "url";
|
|
345
|
+
var log2 = createLogger("Workspace");
|
|
346
|
+
function findPackageRoot() {
|
|
347
|
+
let dir = dirname2(fileURLToPath(import.meta.url));
|
|
348
|
+
for (let i = 0; i < 10; i++) {
|
|
349
|
+
if (existsSync2(join2(dir, "package.json"))) return dir;
|
|
350
|
+
dir = dirname2(dir);
|
|
351
|
+
}
|
|
352
|
+
return process.cwd();
|
|
353
|
+
}
|
|
354
|
+
var TEMPLATES_DIR = join2(findPackageRoot(), "src", "templates");
|
|
355
|
+
async function ensureWorkspace(config) {
|
|
356
|
+
const silent = config?.silent ?? false;
|
|
357
|
+
if (!existsSync2(TELETON_ROOT)) {
|
|
358
|
+
mkdirSync2(TELETON_ROOT, { recursive: true });
|
|
359
|
+
if (!silent) log2.info(`Created Teleton root at ${TELETON_ROOT}`);
|
|
360
|
+
}
|
|
361
|
+
if (!existsSync2(WORKSPACE_ROOT)) {
|
|
362
|
+
mkdirSync2(WORKSPACE_ROOT, { recursive: true });
|
|
363
|
+
if (!silent) log2.info(`Created workspace at ${WORKSPACE_ROOT}`);
|
|
364
|
+
}
|
|
365
|
+
const directories = [
|
|
366
|
+
WORKSPACE_PATHS.MEMORY_DIR,
|
|
367
|
+
WORKSPACE_PATHS.DOWNLOADS_DIR,
|
|
368
|
+
WORKSPACE_PATHS.UPLOADS_DIR,
|
|
369
|
+
WORKSPACE_PATHS.TEMP_DIR,
|
|
370
|
+
WORKSPACE_PATHS.MEMES_DIR
|
|
371
|
+
];
|
|
372
|
+
for (const dir of directories) {
|
|
373
|
+
if (!existsSync2(dir)) {
|
|
374
|
+
mkdirSync2(dir, { recursive: true });
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
const workspace = {
|
|
378
|
+
root: TELETON_ROOT,
|
|
379
|
+
workspace: WORKSPACE_ROOT,
|
|
380
|
+
// Workspace files
|
|
381
|
+
soulPath: WORKSPACE_PATHS.SOUL,
|
|
382
|
+
memoryPath: WORKSPACE_PATHS.MEMORY,
|
|
383
|
+
identityPath: WORKSPACE_PATHS.IDENTITY,
|
|
384
|
+
userPath: WORKSPACE_PATHS.USER,
|
|
385
|
+
strategyPath: WORKSPACE_PATHS.STRATEGY,
|
|
386
|
+
securityPath: WORKSPACE_PATHS.SECURITY,
|
|
387
|
+
// Workspace directories
|
|
388
|
+
memoryDir: WORKSPACE_PATHS.MEMORY_DIR,
|
|
389
|
+
downloadsDir: WORKSPACE_PATHS.DOWNLOADS_DIR,
|
|
390
|
+
uploadsDir: WORKSPACE_PATHS.UPLOADS_DIR,
|
|
391
|
+
tempDir: WORKSPACE_PATHS.TEMP_DIR,
|
|
392
|
+
memesDir: WORKSPACE_PATHS.MEMES_DIR,
|
|
393
|
+
// Protected files (outside workspace)
|
|
394
|
+
sessionPath: join2(TELETON_ROOT, "telegram_session.txt"),
|
|
395
|
+
configPath: join2(TELETON_ROOT, "config.yaml"),
|
|
396
|
+
walletPath: join2(TELETON_ROOT, "wallet.json")
|
|
397
|
+
};
|
|
398
|
+
if (config?.ensureTemplates) {
|
|
399
|
+
await bootstrapTemplates(workspace, silent);
|
|
400
|
+
}
|
|
401
|
+
return workspace;
|
|
402
|
+
}
|
|
403
|
+
async function bootstrapTemplates(workspace, silent = false) {
|
|
404
|
+
const templates = [
|
|
405
|
+
{ name: "SOUL.md", path: workspace.soulPath },
|
|
406
|
+
{ name: "MEMORY.md", path: workspace.memoryPath },
|
|
407
|
+
{ name: "IDENTITY.md", path: workspace.identityPath },
|
|
408
|
+
{ name: "USER.md", path: workspace.userPath },
|
|
409
|
+
{ name: "SECURITY.md", path: workspace.securityPath },
|
|
410
|
+
{ name: "STRATEGY.md", path: workspace.strategyPath },
|
|
411
|
+
{ name: "HEARTBEAT.md", path: WORKSPACE_PATHS.HEARTBEAT }
|
|
412
|
+
];
|
|
413
|
+
for (const template of templates) {
|
|
414
|
+
if (!existsSync2(template.path)) {
|
|
415
|
+
const templateSource = join2(TEMPLATES_DIR, template.name);
|
|
416
|
+
if (existsSync2(templateSource)) {
|
|
417
|
+
copyFileSync(templateSource, template.path);
|
|
418
|
+
if (!silent) log2.info(`Created ${template.name}`);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
function isNewWorkspace(workspace) {
|
|
424
|
+
return !existsSync2(workspace.configPath);
|
|
425
|
+
}
|
|
426
|
+
function loadTemplate(name) {
|
|
427
|
+
const templatePath = join2(TEMPLATES_DIR, name);
|
|
428
|
+
if (!existsSync2(templatePath)) {
|
|
429
|
+
throw new Error(`Template ${name} not found at ${templatePath}`);
|
|
430
|
+
}
|
|
431
|
+
return readFileSync2(templatePath, "utf-8");
|
|
432
|
+
}
|
|
433
|
+
|
|
295
434
|
export {
|
|
296
435
|
DealsConfigSchema,
|
|
297
436
|
ConfigSchema,
|
|
437
|
+
expandPath,
|
|
438
|
+
loadConfig,
|
|
439
|
+
configExists,
|
|
440
|
+
getDefaultConfigPath,
|
|
298
441
|
ensureWorkspace,
|
|
299
442
|
isNewWorkspace,
|
|
300
443
|
loadTemplate
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TELETON_ROOT
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-L653KKCR.js";
|
|
4
4
|
import {
|
|
5
5
|
createLogger
|
|
6
6
|
} from "./chunk-NQ6FZKCE.js";
|
|
@@ -42,7 +42,7 @@ async function ensureModelCached(model) {
|
|
|
42
42
|
}
|
|
43
43
|
const buffer = Buffer.from(await res.arrayBuffer());
|
|
44
44
|
const tmpPath = localPath + ".tmp";
|
|
45
|
-
writeFileSync(tmpPath, buffer);
|
|
45
|
+
writeFileSync(tmpPath, buffer, { mode: 384 });
|
|
46
46
|
renameSync(tmpPath, localPath);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
@@ -11,7 +11,7 @@ var SQLITE_CACHE_SIZE_KB = 64e3;
|
|
|
11
11
|
var SQLITE_MMAP_SIZE = 256e6;
|
|
12
12
|
var SECONDS_PER_DAY = 86400;
|
|
13
13
|
var SECONDS_PER_HOUR = 3600;
|
|
14
|
-
var COMPACTION_MAX_MESSAGES =
|
|
14
|
+
var COMPACTION_MAX_MESSAGES = 1e3;
|
|
15
15
|
var COMPACTION_KEEP_RECENT = 20;
|
|
16
16
|
var COMPACTION_MAX_TOKENS_RATIO = 0.75;
|
|
17
17
|
var COMPACTION_SOFT_THRESHOLD_RATIO = 0.5;
|
|
@@ -11,6 +11,7 @@ var WORKSPACE_PATHS = {
|
|
|
11
11
|
USER: join(WORKSPACE_ROOT, "USER.md"),
|
|
12
12
|
STRATEGY: join(WORKSPACE_ROOT, "STRATEGY.md"),
|
|
13
13
|
SECURITY: join(WORKSPACE_ROOT, "SECURITY.md"),
|
|
14
|
+
HEARTBEAT: join(WORKSPACE_ROOT, "HEARTBEAT.md"),
|
|
14
15
|
// Directories
|
|
15
16
|
MEMORY_DIR: join(WORKSPACE_ROOT, "memory"),
|
|
16
17
|
DOWNLOADS_DIR: join(WORKSPACE_ROOT, "downloads"),
|
|
@@ -13,10 +13,10 @@ import {
|
|
|
13
13
|
SESSION_SLUG_MAX_TOKENS,
|
|
14
14
|
SESSION_SLUG_RECENT_MESSAGES,
|
|
15
15
|
TOKEN_ESTIMATE_SAFETY_MARGIN
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-L3LPVF4Z.js";
|
|
17
17
|
import {
|
|
18
18
|
getUtilityModel
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-4KURCUWD.js";
|
|
20
20
|
import {
|
|
21
21
|
createLogger
|
|
22
22
|
} from "./chunk-NQ6FZKCE.js";
|
|
@@ -352,7 +352,7 @@ Slug:`,
|
|
|
352
352
|
}
|
|
353
353
|
async function saveSessionMemory(params) {
|
|
354
354
|
try {
|
|
355
|
-
const { TELETON_ROOT } = await import("./paths-
|
|
355
|
+
const { TELETON_ROOT } = await import("./paths-WMVV7ZAJ.js");
|
|
356
356
|
const memoryDir = join(TELETON_ROOT, "memory");
|
|
357
357
|
await mkdir(memoryDir, { recursive: true });
|
|
358
358
|
const now = /* @__PURE__ */ new Date();
|
|
@@ -415,7 +415,7 @@ var CONSOLIDATION_THRESHOLD = 20;
|
|
|
415
415
|
var CONSOLIDATION_BATCH = 10;
|
|
416
416
|
async function consolidateOldMemoryFiles(params) {
|
|
417
417
|
try {
|
|
418
|
-
const { TELETON_ROOT } = await import("./paths-
|
|
418
|
+
const { TELETON_ROOT } = await import("./paths-WMVV7ZAJ.js");
|
|
419
419
|
const memoryDir = join(TELETON_ROOT, "memory");
|
|
420
420
|
let entries;
|
|
421
421
|
try {
|