teleton 0.5.1 → 0.6.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.
- package/README.md +239 -101
- package/dist/chunk-2QUJLHCZ.js +362 -0
- package/dist/chunk-4IPJ25HE.js +2839 -0
- package/dist/{chunk-RRB6BWU7.js → chunk-6L6KGATM.js} +1042 -3039
- package/dist/{chunk-BYTHCDZA.js → chunk-ADCMUNYU.js} +65 -496
- package/dist/chunk-D5I7GBV7.js +322 -0
- package/dist/chunk-ECSCVEQQ.js +139 -0
- package/dist/chunk-GDCODBNO.js +72 -0
- package/dist/{chunk-O4R7V5Y2.js → chunk-RO62LO6Z.js} +11 -1
- package/dist/cli/index.js +346 -22
- package/dist/index.js +7 -4
- package/dist/{memory-657W5AS6.js → memory-TVDOGQXS.js} +14 -10
- package/dist/{migrate-PMB2JVXH.js → migrate-QIEMPOMT.js} +5 -2
- package/dist/{server-BQY7CM2N.js → server-RSWVCVY3.js} +805 -26
- package/dist/{task-dependency-resolver-TRPILAHM.js → task-dependency-resolver-72DLY2HV.js} +1 -1
- package/dist/{task-executor-N7XNVK5N.js → task-executor-VXB6DAV2.js} +1 -1
- package/dist/tool-index-DKI2ZNOU.js +245 -0
- package/dist/web/assets/index-BNhrx9S1.js +67 -0
- package/dist/web/assets/index-CqrrRLOh.css +1 -0
- package/dist/web/index.html +2 -2
- package/package.json +16 -16
- package/dist/chunk-5WWR4CU3.js +0 -124
- package/dist/web/assets/index-CDMbujHf.css +0 -1
- package/dist/web/assets/index-DDX8oQ2z.js +0 -67
package/dist/cli/index.js
CHANGED
|
@@ -1,33 +1,45 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CONFIGURABLE_KEYS,
|
|
3
|
+
deleteNestedValue,
|
|
4
|
+
getNestedValue,
|
|
5
|
+
readRawConfig,
|
|
6
|
+
setNestedValue,
|
|
7
|
+
writeRawConfig
|
|
8
|
+
} from "../chunk-2QUJLHCZ.js";
|
|
9
|
+
import {
|
|
10
|
+
TelegramUserClient,
|
|
11
|
+
ensureWorkspace,
|
|
12
|
+
isNewWorkspace,
|
|
13
|
+
main
|
|
14
|
+
} from "../chunk-6L6KGATM.js";
|
|
15
|
+
import "../chunk-WL2Q3VRD.js";
|
|
16
|
+
import "../chunk-EHEV7FJ7.js";
|
|
17
|
+
import "../chunk-U7FQYCBQ.js";
|
|
1
18
|
import {
|
|
2
19
|
ConfigSchema,
|
|
3
20
|
DealsConfigSchema,
|
|
4
|
-
TelegramUserClient,
|
|
5
21
|
configExists,
|
|
6
|
-
ensureWorkspace,
|
|
7
22
|
generateWallet,
|
|
8
23
|
getDefaultConfigPath,
|
|
9
24
|
getProviderMetadata,
|
|
10
25
|
getSupportedProviders,
|
|
11
26
|
importWallet,
|
|
12
|
-
isNewWorkspace,
|
|
13
27
|
loadWallet,
|
|
14
|
-
main,
|
|
15
28
|
saveWallet,
|
|
16
29
|
validateApiKeyFormat,
|
|
17
30
|
walletExists
|
|
18
|
-
} from "../chunk-
|
|
19
|
-
import "../chunk-WL2Q3VRD.js";
|
|
20
|
-
import "../chunk-EHEV7FJ7.js";
|
|
21
|
-
import "../chunk-U7FQYCBQ.js";
|
|
22
|
-
import "../chunk-5WWR4CU3.js";
|
|
31
|
+
} from "../chunk-4IPJ25HE.js";
|
|
23
32
|
import "../chunk-YBA6IBGT.js";
|
|
33
|
+
import "../chunk-ADCMUNYU.js";
|
|
34
|
+
import "../chunk-D5I7GBV7.js";
|
|
35
|
+
import "../chunk-ECSCVEQQ.js";
|
|
24
36
|
import {
|
|
25
37
|
fetchWithTimeout
|
|
26
|
-
} from "../chunk-
|
|
38
|
+
} from "../chunk-GDCODBNO.js";
|
|
27
39
|
import "../chunk-4DU3C27M.js";
|
|
28
40
|
import {
|
|
29
41
|
TELEGRAM_MAX_MESSAGE_LENGTH
|
|
30
|
-
} from "../chunk-
|
|
42
|
+
} from "../chunk-RO62LO6Z.js";
|
|
31
43
|
import {
|
|
32
44
|
TELETON_ROOT
|
|
33
45
|
} from "../chunk-EYWNOHMJ.js";
|
|
@@ -325,7 +337,7 @@ Get it at: ${providerMeta.consoleUrl}`,
|
|
|
325
337
|
prompter.warn(`TELETON_API_KEY env var found but invalid: ${validationError}`);
|
|
326
338
|
apiKey = await prompter.password({
|
|
327
339
|
message: `${providerMeta.displayName} API Key (${providerMeta.keyHint})`,
|
|
328
|
-
validate: (value) => validateApiKeyFormat(selectedProvider, value)
|
|
340
|
+
validate: (value = "") => validateApiKeyFormat(selectedProvider, value)
|
|
329
341
|
});
|
|
330
342
|
} else {
|
|
331
343
|
prompter.log(`Using API key from TELETON_API_KEY env var`);
|
|
@@ -334,7 +346,7 @@ Get it at: ${providerMeta.consoleUrl}`,
|
|
|
334
346
|
} else {
|
|
335
347
|
apiKey = await prompter.password({
|
|
336
348
|
message: `${providerMeta.displayName} API Key (${providerMeta.keyHint})`,
|
|
337
|
-
validate: (value) => validateApiKeyFormat(selectedProvider, value)
|
|
349
|
+
validate: (value = "") => validateApiKeyFormat(selectedProvider, value)
|
|
338
350
|
});
|
|
339
351
|
}
|
|
340
352
|
const MODEL_OPTIONS = {
|
|
@@ -442,7 +454,7 @@ Get it at: ${providerMeta.consoleUrl}`,
|
|
|
442
454
|
maxAgenticIterations = await prompter.text({
|
|
443
455
|
message: "Max agentic iterations (tool call loops per message)",
|
|
444
456
|
initialValue: "5",
|
|
445
|
-
validate: (v) => {
|
|
457
|
+
validate: (v = "") => {
|
|
446
458
|
const n = parseInt(v, 10);
|
|
447
459
|
if (isNaN(n) || n < 1 || n > 50) return "Must be a number between 1 and 50";
|
|
448
460
|
}
|
|
@@ -461,7 +473,7 @@ Get it at: ${providerMeta.consoleUrl}`,
|
|
|
461
473
|
const buyInput = await prompter.text({
|
|
462
474
|
message: "Max buy price (% of floor price)",
|
|
463
475
|
initialValue: "100",
|
|
464
|
-
validate: (v) => {
|
|
476
|
+
validate: (v = "") => {
|
|
465
477
|
const n = parseInt(v, 10);
|
|
466
478
|
if (isNaN(n) || n < 50 || n > 150) return "Must be between 50 and 150";
|
|
467
479
|
}
|
|
@@ -470,7 +482,7 @@ Get it at: ${providerMeta.consoleUrl}`,
|
|
|
470
482
|
const sellInput = await prompter.text({
|
|
471
483
|
message: "Min sell price (% of floor price)",
|
|
472
484
|
initialValue: "105",
|
|
473
|
-
validate: (v) => {
|
|
485
|
+
validate: (v = "") => {
|
|
474
486
|
const n = parseInt(v, 10);
|
|
475
487
|
if (isNaN(n) || n < 100 || n > 200) return "Must be between 100 and 200";
|
|
476
488
|
}
|
|
@@ -530,6 +542,24 @@ Get it at: ${providerMeta.consoleUrl}`,
|
|
|
530
542
|
});
|
|
531
543
|
tonapiKey = keyInput;
|
|
532
544
|
}
|
|
545
|
+
let tavilyApiKey;
|
|
546
|
+
const setupTavily = await prompter.confirm({
|
|
547
|
+
message: "Enable web search? (requires a free Tavily API key \u2014 1,000 req/month, no credit card)",
|
|
548
|
+
initialValue: false
|
|
549
|
+
});
|
|
550
|
+
if (setupTavily) {
|
|
551
|
+
prompter.note(
|
|
552
|
+
"Web search lets your agent search the internet and read web pages.\n\nTo get your free API key (takes 30 seconds):\n\n 1. Go to https://app.tavily.com/sign-in\n 2. Create an account (email or Google/GitHub)\n 3. Your API key is displayed on the dashboard\n (starts with tvly-)\n\nFree plan: 1,000 requests/month \u2014 no credit card required.",
|
|
553
|
+
"Tavily \u2014 Web Search API"
|
|
554
|
+
);
|
|
555
|
+
const keyInput = await prompter.text({
|
|
556
|
+
message: "Tavily API key (starts with tvly-)",
|
|
557
|
+
validate: (v) => {
|
|
558
|
+
if (!v || !v.startsWith("tvly-")) return "Invalid key (should start with tvly-)";
|
|
559
|
+
}
|
|
560
|
+
});
|
|
561
|
+
tavilyApiKey = keyInput;
|
|
562
|
+
}
|
|
533
563
|
const config = {
|
|
534
564
|
meta: {
|
|
535
565
|
version: "1.0.0",
|
|
@@ -579,6 +609,7 @@ Get it at: ${providerMeta.consoleUrl}`,
|
|
|
579
609
|
memory_file: `${workspace.root}/memory.json`,
|
|
580
610
|
history_limit: 100
|
|
581
611
|
},
|
|
612
|
+
embedding: { provider: "local" },
|
|
582
613
|
deals: DealsConfigSchema.parse({
|
|
583
614
|
enabled: dealsEnabled,
|
|
584
615
|
buy_max_floor_percent: buyMaxFloorPercent,
|
|
@@ -592,8 +623,24 @@ Get it at: ${providerMeta.consoleUrl}`,
|
|
|
592
623
|
log_requests: false
|
|
593
624
|
},
|
|
594
625
|
dev: { hot_reload: false },
|
|
626
|
+
tool_rag: {
|
|
627
|
+
enabled: true,
|
|
628
|
+
top_k: 25,
|
|
629
|
+
always_include: [
|
|
630
|
+
"telegram_send_message",
|
|
631
|
+
"telegram_reply_message",
|
|
632
|
+
"telegram_send_photo",
|
|
633
|
+
"telegram_send_document",
|
|
634
|
+
"journal_*",
|
|
635
|
+
"workspace_*",
|
|
636
|
+
"web_*"
|
|
637
|
+
],
|
|
638
|
+
skip_unlimited_providers: false
|
|
639
|
+
},
|
|
640
|
+
mcp: { servers: {} },
|
|
595
641
|
plugins: {},
|
|
596
|
-
tonapi_key: tonapiKey
|
|
642
|
+
tonapi_key: tonapiKey,
|
|
643
|
+
tavily_api_key: tavilyApiKey
|
|
597
644
|
};
|
|
598
645
|
spinner2.start("Saving configuration...");
|
|
599
646
|
const configYaml = YAML.stringify(config);
|
|
@@ -618,7 +665,7 @@ Get it at: ${providerMeta.consoleUrl}`,
|
|
|
618
665
|
} else if (walletAction === "import") {
|
|
619
666
|
const mnemonicInput = await prompter.text({
|
|
620
667
|
message: "Enter your 24-word mnemonic (space-separated)",
|
|
621
|
-
validate: (value) => {
|
|
668
|
+
validate: (value = "") => {
|
|
622
669
|
const words = value.trim().split(/\s+/);
|
|
623
670
|
if (words.length !== 24) return `Expected 24 words, got ${words.length}`;
|
|
624
671
|
}
|
|
@@ -682,7 +729,8 @@ Telegram: ${phone} (API ID: ${apiId})${telegramConnected ? " \u2713 connected" :
|
|
|
682
729
|
Admin: User ID ${userId}
|
|
683
730
|
Provider: ${providerMeta.displayName}
|
|
684
731
|
Model: ${selectedModel}
|
|
685
|
-
TON Wallet: ${wallet.address}
|
|
732
|
+
TON Wallet: ${wallet.address}
|
|
733
|
+
Web Search: ${tavilyApiKey ? "Tavily \u2713" : "disabled (no Tavily key)"}`,
|
|
686
734
|
"Setup complete"
|
|
687
735
|
);
|
|
688
736
|
if (telegramConnected) {
|
|
@@ -760,6 +808,7 @@ async function runNonInteractiveOnboarding(options, prompter) {
|
|
|
760
808
|
memory_file: `${workspace.root}/memory.json`,
|
|
761
809
|
history_limit: 100
|
|
762
810
|
},
|
|
811
|
+
embedding: { provider: "local" },
|
|
763
812
|
deals: DealsConfigSchema.parse({}),
|
|
764
813
|
webui: {
|
|
765
814
|
enabled: false,
|
|
@@ -769,7 +818,23 @@ async function runNonInteractiveOnboarding(options, prompter) {
|
|
|
769
818
|
log_requests: false
|
|
770
819
|
},
|
|
771
820
|
dev: { hot_reload: false },
|
|
772
|
-
|
|
821
|
+
tool_rag: {
|
|
822
|
+
enabled: true,
|
|
823
|
+
top_k: 25,
|
|
824
|
+
always_include: [
|
|
825
|
+
"telegram_send_message",
|
|
826
|
+
"telegram_reply_message",
|
|
827
|
+
"telegram_send_photo",
|
|
828
|
+
"telegram_send_document",
|
|
829
|
+
"journal_*",
|
|
830
|
+
"workspace_*",
|
|
831
|
+
"web_*"
|
|
832
|
+
],
|
|
833
|
+
skip_unlimited_providers: false
|
|
834
|
+
},
|
|
835
|
+
mcp: { servers: {} },
|
|
836
|
+
plugins: {},
|
|
837
|
+
tavily_api_key: options.tavilyApiKey
|
|
773
838
|
};
|
|
774
839
|
const configYaml = YAML.stringify(config);
|
|
775
840
|
writeFileSync(workspace.configPath, configYaml, "utf-8");
|
|
@@ -1157,6 +1222,224 @@ ${blue} \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u250
|
|
|
1157
1222
|
console.log("");
|
|
1158
1223
|
}
|
|
1159
1224
|
|
|
1225
|
+
// src/cli/commands/mcp.ts
|
|
1226
|
+
function ensureMcpSection(raw) {
|
|
1227
|
+
if (!raw.mcp || typeof raw.mcp !== "object") {
|
|
1228
|
+
raw.mcp = { servers: {} };
|
|
1229
|
+
}
|
|
1230
|
+
const mcp2 = raw.mcp;
|
|
1231
|
+
if (!mcp2.servers || typeof mcp2.servers !== "object") {
|
|
1232
|
+
mcp2.servers = {};
|
|
1233
|
+
}
|
|
1234
|
+
return mcp2.servers;
|
|
1235
|
+
}
|
|
1236
|
+
function deriveServerName(pkg) {
|
|
1237
|
+
const unscoped = pkg.includes("/") ? pkg.split("/").pop() : pkg;
|
|
1238
|
+
return unscoped.replace(/^server-/, "").replace(/^mcp-server-/, "").replace(/^mcp-/, "");
|
|
1239
|
+
}
|
|
1240
|
+
async function mcpAddCommand(pkg, extraArgs, options) {
|
|
1241
|
+
const configPath = options.config || getDefaultConfigPath();
|
|
1242
|
+
const raw = readRawConfig(configPath);
|
|
1243
|
+
const servers = ensureMcpSection(raw);
|
|
1244
|
+
const serverName = options.name || deriveServerName(pkg);
|
|
1245
|
+
if (servers[serverName]) {
|
|
1246
|
+
console.error(`\u274C MCP server "${serverName}" already exists. Remove it first or use --name.`);
|
|
1247
|
+
process.exit(1);
|
|
1248
|
+
}
|
|
1249
|
+
const entry = {};
|
|
1250
|
+
if (options.url) {
|
|
1251
|
+
entry.url = pkg;
|
|
1252
|
+
} else {
|
|
1253
|
+
const cmdParts = ["npx", "-y", pkg, ...extraArgs];
|
|
1254
|
+
entry.command = cmdParts.join(" ");
|
|
1255
|
+
}
|
|
1256
|
+
if (options.scope && options.scope !== "always") {
|
|
1257
|
+
entry.scope = options.scope;
|
|
1258
|
+
}
|
|
1259
|
+
if (options.env && options.env.length > 0) {
|
|
1260
|
+
const envMap = {};
|
|
1261
|
+
for (const pair of options.env) {
|
|
1262
|
+
const eq = pair.indexOf("=");
|
|
1263
|
+
if (eq === -1) {
|
|
1264
|
+
console.error(`\u274C Invalid --env format: "${pair}" (expected KEY=VALUE)`);
|
|
1265
|
+
process.exit(1);
|
|
1266
|
+
}
|
|
1267
|
+
envMap[pair.slice(0, eq)] = pair.slice(eq + 1);
|
|
1268
|
+
}
|
|
1269
|
+
entry.env = envMap;
|
|
1270
|
+
}
|
|
1271
|
+
servers[serverName] = entry;
|
|
1272
|
+
writeRawConfig(raw, configPath);
|
|
1273
|
+
console.log(`\u2705 Added MCP server "${serverName}"`);
|
|
1274
|
+
if (entry.command) {
|
|
1275
|
+
console.log(` Command: ${entry.command}`);
|
|
1276
|
+
} else {
|
|
1277
|
+
console.log(` URL: ${entry.url}`);
|
|
1278
|
+
}
|
|
1279
|
+
console.log(`
|
|
1280
|
+
Restart teleton to connect: teleton start`);
|
|
1281
|
+
}
|
|
1282
|
+
async function mcpRemoveCommand(name, options) {
|
|
1283
|
+
const configPath = options.config || getDefaultConfigPath();
|
|
1284
|
+
const raw = readRawConfig(configPath);
|
|
1285
|
+
const servers = ensureMcpSection(raw);
|
|
1286
|
+
if (!servers[name]) {
|
|
1287
|
+
console.error(`\u274C MCP server "${name}" not found.`);
|
|
1288
|
+
const names = Object.keys(servers);
|
|
1289
|
+
if (names.length > 0) {
|
|
1290
|
+
console.error(` Available: ${names.join(", ")}`);
|
|
1291
|
+
}
|
|
1292
|
+
process.exit(1);
|
|
1293
|
+
}
|
|
1294
|
+
delete servers[name];
|
|
1295
|
+
writeRawConfig(raw, configPath);
|
|
1296
|
+
console.log(`\u2705 Removed MCP server "${name}"`);
|
|
1297
|
+
}
|
|
1298
|
+
async function mcpListCommand(options) {
|
|
1299
|
+
const configPath = options.config || getDefaultConfigPath();
|
|
1300
|
+
const raw = readRawConfig(configPath);
|
|
1301
|
+
const servers = ensureMcpSection(raw);
|
|
1302
|
+
const entries = Object.entries(servers);
|
|
1303
|
+
if (entries.length === 0) {
|
|
1304
|
+
console.log("No MCP servers configured.");
|
|
1305
|
+
console.log("\n Add one: teleton mcp add @modelcontextprotocol/server-filesystem /tmp");
|
|
1306
|
+
return;
|
|
1307
|
+
}
|
|
1308
|
+
console.log(`MCP servers (${entries.length}):
|
|
1309
|
+
`);
|
|
1310
|
+
for (const [name, cfg] of entries) {
|
|
1311
|
+
const type = cfg.command ? "stdio" : "sse";
|
|
1312
|
+
const target = cfg.command || cfg.url || "?";
|
|
1313
|
+
const scope = cfg.scope || "always";
|
|
1314
|
+
const enabled = cfg.enabled !== false ? "\u2713" : "\u2717";
|
|
1315
|
+
console.log(` ${enabled} ${name} (${type}, ${scope})`);
|
|
1316
|
+
console.log(` ${target}`);
|
|
1317
|
+
if (cfg.env && typeof cfg.env === "object") {
|
|
1318
|
+
const keys = Object.keys(cfg.env);
|
|
1319
|
+
console.log(` env: ${keys.join(", ")}`);
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1324
|
+
// src/cli/commands/config.ts
|
|
1325
|
+
function requireWhitelisted(key) {
|
|
1326
|
+
const meta = CONFIGURABLE_KEYS[key];
|
|
1327
|
+
if (!meta) {
|
|
1328
|
+
const allowed = Object.keys(CONFIGURABLE_KEYS).join(", ");
|
|
1329
|
+
console.error(`Key "${key}" is not configurable.
|
|
1330
|
+
Allowed keys: ${allowed}`);
|
|
1331
|
+
process.exit(1);
|
|
1332
|
+
}
|
|
1333
|
+
return meta;
|
|
1334
|
+
}
|
|
1335
|
+
async function actionSet(key, value, configPath) {
|
|
1336
|
+
const meta = requireWhitelisted(key);
|
|
1337
|
+
if (!value) {
|
|
1338
|
+
const prompter = createPrompter();
|
|
1339
|
+
try {
|
|
1340
|
+
if (meta.sensitive) {
|
|
1341
|
+
value = await prompter.password({
|
|
1342
|
+
message: `Enter value for ${key}:`,
|
|
1343
|
+
validate: (v) => {
|
|
1344
|
+
if (!v) return "Value is required";
|
|
1345
|
+
const err2 = meta.validate(v);
|
|
1346
|
+
return err2 ? new Error(err2) : void 0;
|
|
1347
|
+
}
|
|
1348
|
+
});
|
|
1349
|
+
} else {
|
|
1350
|
+
value = await prompter.text({
|
|
1351
|
+
message: `Enter value for ${key}:`,
|
|
1352
|
+
validate: (v) => {
|
|
1353
|
+
if (!v) return "Value is required";
|
|
1354
|
+
const err2 = meta.validate(v);
|
|
1355
|
+
return err2 ? new Error(err2) : void 0;
|
|
1356
|
+
}
|
|
1357
|
+
});
|
|
1358
|
+
}
|
|
1359
|
+
} catch (e) {
|
|
1360
|
+
if (e instanceof CancelledError) {
|
|
1361
|
+
console.log("Cancelled.");
|
|
1362
|
+
return;
|
|
1363
|
+
}
|
|
1364
|
+
throw e;
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
const err = meta.validate(value);
|
|
1368
|
+
if (err) {
|
|
1369
|
+
console.error(`Invalid value for ${key}: ${err}`);
|
|
1370
|
+
process.exit(1);
|
|
1371
|
+
}
|
|
1372
|
+
const raw = readRawConfig(configPath);
|
|
1373
|
+
setNestedValue(raw, key, meta.parse(value));
|
|
1374
|
+
writeRawConfig(raw, configPath);
|
|
1375
|
+
console.log(`\u2713 ${key} = ${meta.mask(value)}`);
|
|
1376
|
+
}
|
|
1377
|
+
function actionGet(key, configPath) {
|
|
1378
|
+
const meta = requireWhitelisted(key);
|
|
1379
|
+
const raw = readRawConfig(configPath);
|
|
1380
|
+
const value = getNestedValue(raw, key);
|
|
1381
|
+
if (value == null || value === "") {
|
|
1382
|
+
console.log(`\u2717 ${key} (not set)`);
|
|
1383
|
+
} else {
|
|
1384
|
+
const display = meta.sensitive ? meta.mask(String(value)) : String(value);
|
|
1385
|
+
console.log(`\u2713 ${key} = ${display}`);
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
function actionList(configPath) {
|
|
1389
|
+
const raw = readRawConfig(configPath);
|
|
1390
|
+
console.log("\nConfigurable keys:\n");
|
|
1391
|
+
for (const [key, meta] of Object.entries(CONFIGURABLE_KEYS)) {
|
|
1392
|
+
const value = getNestedValue(raw, key);
|
|
1393
|
+
if (value != null && value !== "") {
|
|
1394
|
+
const display = meta.sensitive ? meta.mask(String(value)) : String(value);
|
|
1395
|
+
console.log(` \u2713 ${key.padEnd(24)} = ${display}`);
|
|
1396
|
+
} else {
|
|
1397
|
+
console.log(` \u2717 ${key.padEnd(24)} (not set)`);
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
console.log();
|
|
1401
|
+
}
|
|
1402
|
+
function actionUnset(key, configPath) {
|
|
1403
|
+
requireWhitelisted(key);
|
|
1404
|
+
const raw = readRawConfig(configPath);
|
|
1405
|
+
deleteNestedValue(raw, key);
|
|
1406
|
+
writeRawConfig(raw, configPath);
|
|
1407
|
+
console.log(`\u2713 ${key} unset`);
|
|
1408
|
+
}
|
|
1409
|
+
async function configCommand(action, key, value, options) {
|
|
1410
|
+
const configPath = options.config ?? getDefaultConfigPath();
|
|
1411
|
+
switch (action) {
|
|
1412
|
+
case "list":
|
|
1413
|
+
actionList(configPath);
|
|
1414
|
+
break;
|
|
1415
|
+
case "get":
|
|
1416
|
+
if (!key) {
|
|
1417
|
+
console.error("Usage: teleton config get <key>");
|
|
1418
|
+
process.exit(1);
|
|
1419
|
+
}
|
|
1420
|
+
actionGet(key, configPath);
|
|
1421
|
+
break;
|
|
1422
|
+
case "set":
|
|
1423
|
+
if (!key) {
|
|
1424
|
+
console.error("Usage: teleton config set <key> [value]");
|
|
1425
|
+
process.exit(1);
|
|
1426
|
+
}
|
|
1427
|
+
await actionSet(key, value, configPath);
|
|
1428
|
+
break;
|
|
1429
|
+
case "unset":
|
|
1430
|
+
if (!key) {
|
|
1431
|
+
console.error("Usage: teleton config unset <key>");
|
|
1432
|
+
process.exit(1);
|
|
1433
|
+
}
|
|
1434
|
+
actionUnset(key, configPath);
|
|
1435
|
+
break;
|
|
1436
|
+
default:
|
|
1437
|
+
console.error(`Unknown action: ${action}
|
|
1438
|
+
Available: set, get, list, unset`);
|
|
1439
|
+
process.exit(1);
|
|
1440
|
+
}
|
|
1441
|
+
}
|
|
1442
|
+
|
|
1160
1443
|
// src/cli/index.ts
|
|
1161
1444
|
import { readFileSync as readFileSync3, existsSync as existsSync3 } from "fs";
|
|
1162
1445
|
import { dirname, join as join3 } from "path";
|
|
@@ -1175,7 +1458,7 @@ function findPackageJson() {
|
|
|
1175
1458
|
var packageJson = findPackageJson();
|
|
1176
1459
|
var program = new Command();
|
|
1177
1460
|
program.name("teleton").description("Teleton Agent - Personal AI Agent for Telegram").version(packageJson.version);
|
|
1178
|
-
program.command("setup").description("Interactive wizard to set up Teleton").option("--workspace <dir>", "Workspace directory").option("--non-interactive", "Non-interactive mode").option("--api-id <id>", "Telegram API ID").option("--api-hash <hash>", "Telegram API Hash").option("--phone <number>", "Phone number").option("--api-key <key>", "Anthropic API key").option("--user-id <id>", "Telegram User ID").action(async (options) => {
|
|
1461
|
+
program.command("setup").description("Interactive wizard to set up Teleton").option("--workspace <dir>", "Workspace directory").option("--non-interactive", "Non-interactive mode").option("--api-id <id>", "Telegram API ID").option("--api-hash <hash>", "Telegram API Hash").option("--phone <number>", "Phone number").option("--api-key <key>", "Anthropic API key").option("--user-id <id>", "Telegram User ID").option("--tavily-api-key <key>", "Tavily API key for web search").action(async (options) => {
|
|
1179
1462
|
try {
|
|
1180
1463
|
await onboardCommand({
|
|
1181
1464
|
workspace: options.workspace,
|
|
@@ -1184,7 +1467,8 @@ program.command("setup").description("Interactive wizard to set up Teleton").opt
|
|
|
1184
1467
|
apiHash: options.apiHash,
|
|
1185
1468
|
phone: options.phone,
|
|
1186
1469
|
apiKey: options.apiKey,
|
|
1187
|
-
userId: options.userId ? parseInt(options.userId) : void 0
|
|
1470
|
+
userId: options.userId ? parseInt(options.userId) : void 0,
|
|
1471
|
+
tavilyApiKey: options.tavilyApiKey
|
|
1188
1472
|
});
|
|
1189
1473
|
} catch (error) {
|
|
1190
1474
|
console.error("Error:", error instanceof Error ? error.message : String(error));
|
|
@@ -1219,6 +1503,46 @@ program.command("doctor").description("Run system health checks").action(async (
|
|
|
1219
1503
|
process.exit(1);
|
|
1220
1504
|
}
|
|
1221
1505
|
});
|
|
1506
|
+
var mcp = program.command("mcp").description("Manage MCP (Model Context Protocol) servers");
|
|
1507
|
+
mcp.command("add <package> [args...]").description(
|
|
1508
|
+
"Add an MCP server (e.g. teleton mcp add @modelcontextprotocol/server-filesystem /tmp)"
|
|
1509
|
+
).option("-n, --name <name>", "Server name (auto-derived from package if omitted)").option("-s, --scope <scope>", "Tool scope: always | dm-only | group-only | admin-only", "always").option(
|
|
1510
|
+
"-e, --env <KEY=VALUE...>",
|
|
1511
|
+
"Environment variables (repeatable)",
|
|
1512
|
+
(v, prev) => [...prev, v],
|
|
1513
|
+
[]
|
|
1514
|
+
).option("--url", "Treat <package> as an SSE/HTTP URL instead of an npx package").option("-c, --config <path>", "Config file path").action(async (pkg, args, options) => {
|
|
1515
|
+
try {
|
|
1516
|
+
await mcpAddCommand(pkg, args, options);
|
|
1517
|
+
} catch (error) {
|
|
1518
|
+
console.error("Error:", error instanceof Error ? error.message : String(error));
|
|
1519
|
+
process.exit(1);
|
|
1520
|
+
}
|
|
1521
|
+
});
|
|
1522
|
+
mcp.command("remove <name>").description("Remove an MCP server by name").option("-c, --config <path>", "Config file path").action(async (name, options) => {
|
|
1523
|
+
try {
|
|
1524
|
+
await mcpRemoveCommand(name, options);
|
|
1525
|
+
} catch (error) {
|
|
1526
|
+
console.error("Error:", error instanceof Error ? error.message : String(error));
|
|
1527
|
+
process.exit(1);
|
|
1528
|
+
}
|
|
1529
|
+
});
|
|
1530
|
+
mcp.command("list").description("List configured MCP servers").option("-c, --config <path>", "Config file path").action(async (options) => {
|
|
1531
|
+
try {
|
|
1532
|
+
await mcpListCommand(options);
|
|
1533
|
+
} catch (error) {
|
|
1534
|
+
console.error("Error:", error instanceof Error ? error.message : String(error));
|
|
1535
|
+
process.exit(1);
|
|
1536
|
+
}
|
|
1537
|
+
});
|
|
1538
|
+
program.command("config").description("Manage configuration keys (set, get, list, unset)").argument("<action>", "set | get | list | unset").argument("[key]", "Config key (e.g., tavily_api_key, telegram.bot_token)").argument("[value]", "Value to set (prompts interactively if omitted)").option("-c, --config <path>", "Config file path").action(async (action, key, value, options) => {
|
|
1539
|
+
try {
|
|
1540
|
+
await configCommand(action, key, value, options);
|
|
1541
|
+
} catch (error) {
|
|
1542
|
+
console.error("Error:", error instanceof Error ? error.message : String(error));
|
|
1543
|
+
process.exit(1);
|
|
1544
|
+
}
|
|
1545
|
+
});
|
|
1222
1546
|
program.action(() => {
|
|
1223
1547
|
program.help();
|
|
1224
1548
|
});
|
package/dist/index.js
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TeletonApp,
|
|
3
3
|
main
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-6L6KGATM.js";
|
|
5
5
|
import "./chunk-WL2Q3VRD.js";
|
|
6
6
|
import "./chunk-EHEV7FJ7.js";
|
|
7
7
|
import "./chunk-U7FQYCBQ.js";
|
|
8
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-4IPJ25HE.js";
|
|
9
9
|
import "./chunk-YBA6IBGT.js";
|
|
10
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-ADCMUNYU.js";
|
|
11
|
+
import "./chunk-D5I7GBV7.js";
|
|
12
|
+
import "./chunk-ECSCVEQQ.js";
|
|
13
|
+
import "./chunk-GDCODBNO.js";
|
|
11
14
|
import "./chunk-4DU3C27M.js";
|
|
12
|
-
import "./chunk-
|
|
15
|
+
import "./chunk-RO62LO6Z.js";
|
|
13
16
|
import "./chunk-EYWNOHMJ.js";
|
|
14
17
|
import "./chunk-NUGDTPE4.js";
|
|
15
18
|
import "./chunk-QUAPFI2N.js";
|
|
@@ -1,32 +1,36 @@
|
|
|
1
1
|
import {
|
|
2
|
-
AnthropicEmbeddingProvider,
|
|
3
2
|
CURRENT_SCHEMA_VERSION,
|
|
4
|
-
CachedEmbeddingProvider,
|
|
5
3
|
ChatStore,
|
|
6
4
|
ContextBuilder,
|
|
7
5
|
HybridSearch,
|
|
8
6
|
KnowledgeIndexer,
|
|
9
|
-
LocalEmbeddingProvider,
|
|
10
7
|
MemoryDatabase,
|
|
11
8
|
MessageStore,
|
|
12
|
-
NoopEmbeddingProvider,
|
|
13
9
|
SessionStore,
|
|
14
10
|
UserStore,
|
|
15
11
|
closeDatabase,
|
|
16
|
-
createEmbeddingProvider,
|
|
17
|
-
deserializeEmbedding,
|
|
18
12
|
ensureSchema,
|
|
19
13
|
ensureVectorTables,
|
|
20
14
|
getDatabase,
|
|
21
15
|
getSchemaVersion,
|
|
22
|
-
hashText,
|
|
23
16
|
initializeMemory,
|
|
24
17
|
runMigrations,
|
|
25
|
-
serializeEmbedding,
|
|
26
18
|
setSchemaVersion
|
|
27
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-ADCMUNYU.js";
|
|
20
|
+
import {
|
|
21
|
+
AnthropicEmbeddingProvider,
|
|
22
|
+
CachedEmbeddingProvider,
|
|
23
|
+
LocalEmbeddingProvider,
|
|
24
|
+
NoopEmbeddingProvider,
|
|
25
|
+
createEmbeddingProvider,
|
|
26
|
+
deserializeEmbedding,
|
|
27
|
+
hashText,
|
|
28
|
+
serializeEmbedding
|
|
29
|
+
} from "./chunk-D5I7GBV7.js";
|
|
30
|
+
import "./chunk-ECSCVEQQ.js";
|
|
31
|
+
import "./chunk-GDCODBNO.js";
|
|
28
32
|
import "./chunk-4DU3C27M.js";
|
|
29
|
-
import "./chunk-
|
|
33
|
+
import "./chunk-RO62LO6Z.js";
|
|
30
34
|
import "./chunk-EYWNOHMJ.js";
|
|
31
35
|
import {
|
|
32
36
|
TaskStore,
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getDatabase
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ADCMUNYU.js";
|
|
4
|
+
import "./chunk-D5I7GBV7.js";
|
|
5
|
+
import "./chunk-ECSCVEQQ.js";
|
|
6
|
+
import "./chunk-GDCODBNO.js";
|
|
4
7
|
import "./chunk-4DU3C27M.js";
|
|
5
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-RO62LO6Z.js";
|
|
6
9
|
import {
|
|
7
10
|
TELETON_ROOT
|
|
8
11
|
} from "./chunk-EYWNOHMJ.js";
|