@locusai/telegram 0.9.7 → 0.9.9
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 +2 -2
- package/bin/telegram.js +49 -22
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -34,10 +34,10 @@ LOCUS_PROJECT_PATH="/path/to/your/project"
|
|
|
34
34
|
```json
|
|
35
35
|
{
|
|
36
36
|
"apiKey": "your-locus-api-key",
|
|
37
|
+
"agentCount": 2,
|
|
37
38
|
"telegram": {
|
|
38
39
|
"botToken": "your-bot-token",
|
|
39
40
|
"chatId": 123456789,
|
|
40
|
-
"agentCount": 1,
|
|
41
41
|
"testMode": false
|
|
42
42
|
}
|
|
43
43
|
}
|
|
@@ -105,7 +105,7 @@ bun run dev
|
|
|
105
105
|
| API Base URL | — | `apiUrl` | Custom API URL |
|
|
106
106
|
| Provider | — | `provider` | AI provider (`claude` or `codex`) |
|
|
107
107
|
| Model | — | `model` | AI model override |
|
|
108
|
-
| Agent Count |
|
|
108
|
+
| Agent Count | `LOCUS_AGENT_COUNT` | `agentCount` | Number of agents to spawn with `/run` (1-5) |
|
|
109
109
|
| Test Mode | `LOCUS_TEST_MODE` | `telegram.testMode` | Use local CLI source instead of published binary |
|
|
110
110
|
|
|
111
111
|
## Security
|
package/bin/telegram.js
CHANGED
|
@@ -19868,6 +19868,32 @@ function splitMessage(text, maxLength = MAX_MESSAGE_LENGTH) {
|
|
|
19868
19868
|
|
|
19869
19869
|
// src/shell-executor.ts
|
|
19870
19870
|
import { spawn } from "node:child_process";
|
|
19871
|
+
|
|
19872
|
+
// src/env.ts
|
|
19873
|
+
import { homedir } from "node:os";
|
|
19874
|
+
import { join } from "node:path";
|
|
19875
|
+
function extraPathDirs() {
|
|
19876
|
+
const home = homedir();
|
|
19877
|
+
return [
|
|
19878
|
+
join(home, ".bun", "bin"),
|
|
19879
|
+
join(home, ".nvm", "current", "bin"),
|
|
19880
|
+
join(home, ".local", "bin"),
|
|
19881
|
+
"/usr/local/bin"
|
|
19882
|
+
];
|
|
19883
|
+
}
|
|
19884
|
+
function buildSpawnEnv() {
|
|
19885
|
+
const existing = process.env.PATH ?? "";
|
|
19886
|
+
const extras = extraPathDirs().filter((d) => !existing.includes(d));
|
|
19887
|
+
const augmentedPath = [...extras, existing].filter(Boolean).join(":");
|
|
19888
|
+
return {
|
|
19889
|
+
...process.env,
|
|
19890
|
+
PATH: augmentedPath,
|
|
19891
|
+
FORCE_COLOR: "0",
|
|
19892
|
+
NO_COLOR: "1"
|
|
19893
|
+
};
|
|
19894
|
+
}
|
|
19895
|
+
|
|
19896
|
+
// src/shell-executor.ts
|
|
19871
19897
|
function timestamp() {
|
|
19872
19898
|
return new Date().toLocaleTimeString("en-GB", { hour12: false });
|
|
19873
19899
|
}
|
|
@@ -19882,11 +19908,7 @@ function executeShellCommand(command, options) {
|
|
|
19882
19908
|
return new Promise((resolve) => {
|
|
19883
19909
|
const proc = spawn(command.binary, command.args, {
|
|
19884
19910
|
cwd: options.cwd,
|
|
19885
|
-
env:
|
|
19886
|
-
...process.env,
|
|
19887
|
-
FORCE_COLOR: "0",
|
|
19888
|
-
NO_COLOR: "1"
|
|
19889
|
-
},
|
|
19911
|
+
env: buildSpawnEnv(),
|
|
19890
19912
|
stdio: ["pipe", "pipe", "pipe"]
|
|
19891
19913
|
});
|
|
19892
19914
|
let stdout = "";
|
|
@@ -20195,7 +20217,21 @@ async function cancelCommand(ctx, executor) {
|
|
|
20195
20217
|
// src/commands/run.ts
|
|
20196
20218
|
var activeRunKill = null;
|
|
20197
20219
|
async function runCommand(ctx, executor, config) {
|
|
20198
|
-
|
|
20220
|
+
const text = (ctx.message && "text" in ctx.message ? ctx.message.text : "") || "";
|
|
20221
|
+
const input = text.replace(/^\/run\s*/, "").trim();
|
|
20222
|
+
let parsedAgentCount;
|
|
20223
|
+
const agentsMatch = input.match(/(?:--agents|-a)\s+(\d+)/);
|
|
20224
|
+
if (agentsMatch) {
|
|
20225
|
+
parsedAgentCount = Number.parseInt(agentsMatch[1], 10);
|
|
20226
|
+
if (parsedAgentCount < 1 || parsedAgentCount > 5) {
|
|
20227
|
+
await ctx.reply(formatError("Agent count must be between 1 and 5."), {
|
|
20228
|
+
parse_mode: "HTML"
|
|
20229
|
+
});
|
|
20230
|
+
return;
|
|
20231
|
+
}
|
|
20232
|
+
}
|
|
20233
|
+
const agentCount = parsedAgentCount ?? config.agentCount ?? 1;
|
|
20234
|
+
console.log(`[run] Starting agents (count: ${agentCount})`);
|
|
20199
20235
|
if (!config.apiKey) {
|
|
20200
20236
|
await ctx.reply(formatError("API key is not configured. Run: locus config setup --api-key <key>"), { parse_mode: "HTML" });
|
|
20201
20237
|
return;
|
|
@@ -20204,7 +20240,6 @@ async function runCommand(ctx, executor, config) {
|
|
|
20204
20240
|
await ctx.reply(formatInfo("Agents are already running. Use /stop to stop them first."), { parse_mode: "HTML" });
|
|
20205
20241
|
return;
|
|
20206
20242
|
}
|
|
20207
|
-
const agentCount = config.agentCount ?? 1;
|
|
20208
20243
|
const agentLabel = agentCount > 1 ? `${agentCount} agents` : "1 agent";
|
|
20209
20244
|
await ctx.reply(formatInfo(`Starting ${agentLabel}...`), {
|
|
20210
20245
|
parse_mode: "HTML"
|
|
@@ -38490,7 +38525,7 @@ Feedback: <i>${escapeHtml(feedback)}</i>`, { parse_mode: "HTML" });
|
|
|
38490
38525
|
}
|
|
38491
38526
|
// src/executor.ts
|
|
38492
38527
|
import { spawn as spawn2 } from "node:child_process";
|
|
38493
|
-
import { join } from "node:path";
|
|
38528
|
+
import { join as join2 } from "node:path";
|
|
38494
38529
|
function timestamp2() {
|
|
38495
38530
|
return new Date().toLocaleTimeString("en-GB", { hour12: false });
|
|
38496
38531
|
}
|
|
@@ -38506,7 +38541,7 @@ class CliExecutor {
|
|
|
38506
38541
|
}
|
|
38507
38542
|
resolveCommand(args) {
|
|
38508
38543
|
if (this.config.testMode) {
|
|
38509
|
-
const cliPath =
|
|
38544
|
+
const cliPath = join2(this.config.projectPath, "packages/cli/src/cli.ts");
|
|
38510
38545
|
return { cmd: "bun", cmdArgs: ["run", cliPath, ...args] };
|
|
38511
38546
|
}
|
|
38512
38547
|
return { cmd: "locus", cmdArgs: args };
|
|
@@ -38521,11 +38556,7 @@ class CliExecutor {
|
|
|
38521
38556
|
return new Promise((resolve) => {
|
|
38522
38557
|
const proc = spawn2(cmd, cmdArgs, {
|
|
38523
38558
|
cwd: this.config.projectPath,
|
|
38524
|
-
env:
|
|
38525
|
-
...process.env,
|
|
38526
|
-
FORCE_COLOR: "0",
|
|
38527
|
-
NO_COLOR: "1"
|
|
38528
|
-
},
|
|
38559
|
+
env: buildSpawnEnv(),
|
|
38529
38560
|
stdio: ["pipe", "pipe", "pipe"]
|
|
38530
38561
|
});
|
|
38531
38562
|
this.runningProcesses.set(id, {
|
|
@@ -38575,11 +38606,7 @@ class CliExecutor {
|
|
|
38575
38606
|
log2(id, `Process started (streaming): ${fullCommand}`);
|
|
38576
38607
|
const proc = spawn2(cmd, cmdArgs, {
|
|
38577
38608
|
cwd: this.config.projectPath,
|
|
38578
|
-
env:
|
|
38579
|
-
...process.env,
|
|
38580
|
-
FORCE_COLOR: "0",
|
|
38581
|
-
NO_COLOR: "1"
|
|
38582
|
-
},
|
|
38609
|
+
env: buildSpawnEnv(),
|
|
38583
38610
|
stdio: ["pipe", "pipe", "pipe"]
|
|
38584
38611
|
});
|
|
38585
38612
|
this.runningProcesses.set(id, {
|
|
@@ -38715,12 +38742,12 @@ function createBot(config2) {
|
|
|
38715
38742
|
// src/config.ts
|
|
38716
38743
|
var import_dotenv = __toESM(require_main(), 1);
|
|
38717
38744
|
import { existsSync, readFileSync } from "node:fs";
|
|
38718
|
-
import { join as
|
|
38745
|
+
import { join as join3 } from "node:path";
|
|
38719
38746
|
import_dotenv.default.config();
|
|
38720
38747
|
var SETTINGS_FILE = "settings.json";
|
|
38721
38748
|
var CONFIG_DIR = ".locus";
|
|
38722
38749
|
function loadSettings(projectPath) {
|
|
38723
|
-
const settingsPath =
|
|
38750
|
+
const settingsPath = join3(projectPath, CONFIG_DIR, SETTINGS_FILE);
|
|
38724
38751
|
if (!existsSync(settingsPath)) {
|
|
38725
38752
|
return null;
|
|
38726
38753
|
}
|
|
@@ -38758,7 +38785,7 @@ function resolveConfig() {
|
|
|
38758
38785
|
workspaceId: process.env.LOCUS_WORKSPACE_ID || settings?.workspaceId || undefined,
|
|
38759
38786
|
provider: process.env.LOCUS_PROVIDER || settings?.provider || undefined,
|
|
38760
38787
|
model: process.env.LOCUS_MODEL || settings?.model || undefined,
|
|
38761
|
-
agentCount:
|
|
38788
|
+
agentCount: process.env.LOCUS_AGENT_COUNT ? Number.parseInt(process.env.LOCUS_AGENT_COUNT, 10) : settings?.agentCount,
|
|
38762
38789
|
testMode: isTestMode
|
|
38763
38790
|
};
|
|
38764
38791
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@locusai/telegram",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.9",
|
|
4
4
|
"description": "Telegram bot for Locus - remote control your AI agents from Telegram",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"author": "",
|
|
33
33
|
"license": "MIT",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@locusai/sdk": "^0.9.
|
|
35
|
+
"@locusai/sdk": "^0.9.9",
|
|
36
36
|
"dotenv": "^16.4.7",
|
|
37
37
|
"telegraf": "^4.16.3"
|
|
38
38
|
},
|