@ebowwa/stack 0.3.2 → 0.4.1
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/dist/index.js +19 -93
- package/package.json +12 -8
- package/src/index.ts +12 -81
package/dist/index.js
CHANGED
|
@@ -49158,9 +49158,7 @@ var init_conversation_memory = () => {};
|
|
|
49158
49158
|
function registerStartCommand(bot, _memory, _tools) {
|
|
49159
49159
|
bot.onText(/\/start/, async (msg) => {
|
|
49160
49160
|
const chatId = msg.chat.id;
|
|
49161
|
-
await bot.sendMessage(chatId, `\uD83D\uDC4B Hello!
|
|
49162
|
-
|
|
49163
|
-
` + `\uD83E\uDDE0 Powered by GLM-4.7 via Z.AI API
|
|
49161
|
+
await bot.sendMessage(chatId, `\uD83D\uDC4B Hello!
|
|
49164
49162
|
|
|
49165
49163
|
` + `Commands:
|
|
49166
49164
|
` + `/start - Show this message
|
|
@@ -49171,7 +49169,7 @@ function registerStartCommand(bot, _memory, _tools) {
|
|
|
49171
49169
|
` + `/clear - Clear conversation memory
|
|
49172
49170
|
` + `/help - Show help
|
|
49173
49171
|
|
|
49174
|
-
` + "Or just send any message for
|
|
49172
|
+
` + "Or just send any message for assistance!");
|
|
49175
49173
|
});
|
|
49176
49174
|
}
|
|
49177
49175
|
|
|
@@ -49196,9 +49194,8 @@ function registerStatusCommand(bot, _memory, _tools) {
|
|
|
49196
49194
|
bot.onText(/\/status/, async (msg) => {
|
|
49197
49195
|
const chatId = msg.chat.id;
|
|
49198
49196
|
const apiKey = getZAIKey();
|
|
49199
|
-
await bot.sendMessage(chatId, `*
|
|
49197
|
+
await bot.sendMessage(chatId, `*API Status*
|
|
49200
49198
|
|
|
49201
|
-
` + `*AI:* GLM-4.7 via Z.AI
|
|
49202
49199
|
` + `*API:* ${apiKey ? "Connected" : "Disconnected"}`, { parse_mode: "Markdown" });
|
|
49203
49200
|
});
|
|
49204
49201
|
}
|
|
@@ -49208,9 +49205,7 @@ var init_status = () => {};
|
|
|
49208
49205
|
function registerHelpCommand(bot, _memory, _tools) {
|
|
49209
49206
|
bot.onText(/\/help/, async (msg) => {
|
|
49210
49207
|
const chatId = msg.chat.id;
|
|
49211
|
-
await bot.sendMessage(chatId, `\uD83D\uDCDA *
|
|
49212
|
-
|
|
49213
|
-
` + `\uD83E\uDDE0 Powered by GLM-4.7 via Z.AI API
|
|
49208
|
+
await bot.sendMessage(chatId, `\uD83D\uDCDA *Bot Help*
|
|
49214
49209
|
|
|
49215
49210
|
` + `*Commands:*
|
|
49216
49211
|
` + `/start - Show welcome message
|
|
@@ -49224,14 +49219,10 @@ function registerHelpCommand(bot, _memory, _tools) {
|
|
|
49224
49219
|
` + `/resources - Show system resources
|
|
49225
49220
|
` + `/logs [n] - Show last n log lines
|
|
49226
49221
|
` + `/toolsoutput [on|off] - Toggle tool output messages
|
|
49227
|
-
` + `/innerthoughts [msg] - Ask the inner monologue
|
|
49228
49222
|
` + `/help - Show this help
|
|
49229
49223
|
|
|
49230
49224
|
` + `*Usage:*
|
|
49231
|
-
` +
|
|
49232
|
-
|
|
49233
|
-
` + `*Mentions:*
|
|
49234
|
-
` + "@innerthoughts in any message triggers the inner monologue.", { parse_mode: "Markdown" });
|
|
49225
|
+
` + "Just send any message for assistance!", { parse_mode: "Markdown" });
|
|
49235
49226
|
});
|
|
49236
49227
|
}
|
|
49237
49228
|
|
|
@@ -49658,51 +49649,6 @@ var init_verbose = __esm(() => {
|
|
|
49658
49649
|
QUIET_FLAG2 = `${STATE_DIR5}/.quiet`;
|
|
49659
49650
|
});
|
|
49660
49651
|
|
|
49661
|
-
// ../channel-telegram/dist/commands/innerthoughts.js
|
|
49662
|
-
async function askMonologue(question) {
|
|
49663
|
-
try {
|
|
49664
|
-
const res = await fetch(`${MONOLOGUE_URL}/ask`, {
|
|
49665
|
-
method: "POST",
|
|
49666
|
-
headers: { "Content-Type": "application/json" },
|
|
49667
|
-
body: JSON.stringify({ question })
|
|
49668
|
-
});
|
|
49669
|
-
if (!res.ok) {
|
|
49670
|
-
return `Monologue error: ${res.status}`;
|
|
49671
|
-
}
|
|
49672
|
-
const data = await res.json();
|
|
49673
|
-
let thought = data.thought || "...";
|
|
49674
|
-
thought = thought.replace(/[*_\[\]]/g, "").replace(/\n+/g, " ").trim().slice(0, 400);
|
|
49675
|
-
return thought;
|
|
49676
|
-
} catch (error) {
|
|
49677
|
-
return `Could not reach inner monologue: ${error.message}`;
|
|
49678
|
-
}
|
|
49679
|
-
}
|
|
49680
|
-
function registerInnerthoughtsCommand(bot, _memory, _tools) {
|
|
49681
|
-
bot.onText(/\/innerthoughts(?:\s+(.+))?/, async (msg, match) => {
|
|
49682
|
-
const chatId = msg.chat.id;
|
|
49683
|
-
const question = match?.[1]?.trim() || "What are you thinking about?";
|
|
49684
|
-
bot.sendChatAction(chatId, "typing");
|
|
49685
|
-
const thought = await askMonologue(question);
|
|
49686
|
-
await bot.sendMessage(chatId, `\uD83D\uDCAD *Inner Monologue*
|
|
49687
|
-
|
|
49688
|
-
_${thought}_`, { parse_mode: "Markdown" });
|
|
49689
|
-
});
|
|
49690
|
-
bot.on("text", async (msg) => {
|
|
49691
|
-
const text = msg.text || "";
|
|
49692
|
-
if (text.toLowerCase().includes("@innerthoughts")) {
|
|
49693
|
-
const chatId = msg.chat.id;
|
|
49694
|
-
const question = text.replace(/@innerthoughts/gi, "").trim() || "Hello?";
|
|
49695
|
-
bot.sendChatAction(chatId, "typing");
|
|
49696
|
-
const thought = await askMonologue(question);
|
|
49697
|
-
await bot.sendMessage(chatId, `\uD83D\uDCAD _${thought}_`, { parse_mode: "Markdown" });
|
|
49698
|
-
}
|
|
49699
|
-
});
|
|
49700
|
-
}
|
|
49701
|
-
var MONOLOGUE_URL;
|
|
49702
|
-
var init_innerthoughts = __esm(() => {
|
|
49703
|
-
MONOLOGUE_URL = process.env.MONOLOGUE_URL || "http://localhost:8920";
|
|
49704
|
-
});
|
|
49705
|
-
|
|
49706
49652
|
// ../channel-telegram/dist/commands/restart.js
|
|
49707
49653
|
import { execSync as execSync7 } from "child_process";
|
|
49708
49654
|
function register(bot, tools) {
|
|
@@ -49747,7 +49693,6 @@ function registerAllCommands(bot, memory, tools) {
|
|
|
49747
49693
|
registerResumeCommand(bot, memory, tools);
|
|
49748
49694
|
registerQuietCommand(bot, memory, tools);
|
|
49749
49695
|
registerVerboseCommand(bot, memory, tools);
|
|
49750
|
-
registerInnerthoughtsCommand(bot, memory, tools);
|
|
49751
49696
|
register(bot, tools);
|
|
49752
49697
|
}
|
|
49753
49698
|
var init_commands = __esm(() => {
|
|
@@ -49761,7 +49706,6 @@ var init_commands = __esm(() => {
|
|
|
49761
49706
|
init_resume();
|
|
49762
49707
|
init_quiet();
|
|
49763
49708
|
init_verbose();
|
|
49764
|
-
init_innerthoughts();
|
|
49765
49709
|
init_restart();
|
|
49766
49710
|
init_restart();
|
|
49767
49711
|
init_status();
|
|
@@ -49774,7 +49718,6 @@ var init_commands = __esm(() => {
|
|
|
49774
49718
|
init_resume();
|
|
49775
49719
|
init_quiet();
|
|
49776
49720
|
init_verbose();
|
|
49777
|
-
init_innerthoughts();
|
|
49778
49721
|
});
|
|
49779
49722
|
|
|
49780
49723
|
// ../channel-telegram/dist/utils/normalize.js
|
|
@@ -50075,6 +50018,7 @@ class TelegramChannel {
|
|
|
50075
50018
|
{ command: "logs", description: "View recent logs" },
|
|
50076
50019
|
{ command: "clear", description: "Clear conversation history" },
|
|
50077
50020
|
{ command: "tools", description: "List available tools" },
|
|
50021
|
+
{ command: "resources", description: "Show system resources" },
|
|
50078
50022
|
{ command: "restart", description: "Restart the bot service" },
|
|
50079
50023
|
{ command: "cancel", description: "Stop current task" },
|
|
50080
50024
|
{ command: "quiet", description: "Hide tool logging" },
|
|
@@ -56705,13 +56649,22 @@ class GLMNetworkError extends Error {
|
|
|
56705
56649
|
function resolveApiKey(apiKey) {
|
|
56706
56650
|
if (apiKey)
|
|
56707
56651
|
return apiKey;
|
|
56652
|
+
const keysArray = process.env.Z_AI_API_KEYS || process.env.ZAI_API_KEYS;
|
|
56653
|
+
if (keysArray) {
|
|
56654
|
+
try {
|
|
56655
|
+
const keys = JSON.parse(keysArray);
|
|
56656
|
+
if (keys.length > 0) {
|
|
56657
|
+
return keys[0];
|
|
56658
|
+
}
|
|
56659
|
+
} catch {}
|
|
56660
|
+
}
|
|
56708
56661
|
if (process.env.Z_AI_API_KEY)
|
|
56709
56662
|
return process.env.Z_AI_API_KEY;
|
|
56710
56663
|
if (process.env.ZAI_API_KEY)
|
|
56711
56664
|
return process.env.ZAI_API_KEY;
|
|
56712
56665
|
if (process.env.GLM_API_KEY)
|
|
56713
56666
|
return process.env.GLM_API_KEY;
|
|
56714
|
-
throw new Error("GLM API key not found. Set Z_AI_API_KEY, ZAI_API_KEY, or GLM_API_KEY
|
|
56667
|
+
throw new Error("GLM API key not found. Set Z_AI_API_KEYS (JSON array), Z_AI_API_KEY, ZAI_API_KEY, or GLM_API_KEY.");
|
|
56715
56668
|
}
|
|
56716
56669
|
function formatLatency(ms) {
|
|
56717
56670
|
if (ms < 1000)
|
|
@@ -57406,9 +57359,6 @@ class Stack {
|
|
|
57406
57359
|
executor;
|
|
57407
57360
|
channels = new Map;
|
|
57408
57361
|
abortController = null;
|
|
57409
|
-
ralphService = null;
|
|
57410
|
-
gitService = null;
|
|
57411
|
-
consoleLogger = null;
|
|
57412
57362
|
constructor(config) {
|
|
57413
57363
|
this.config = {
|
|
57414
57364
|
...config,
|
|
@@ -57419,8 +57369,7 @@ class Stack {
|
|
|
57419
57369
|
this.state = {
|
|
57420
57370
|
started: new Date,
|
|
57421
57371
|
channels: { ssh: false, telegram: false },
|
|
57422
|
-
api: { enabled: !!this.config.api, port: this.config.api?.port }
|
|
57423
|
-
nodeAgent: { enabled: false }
|
|
57372
|
+
api: { enabled: !!this.config.api, port: this.config.api?.port }
|
|
57424
57373
|
};
|
|
57425
57374
|
const memoryChannels = {};
|
|
57426
57375
|
const permissions = {};
|
|
@@ -57445,7 +57394,7 @@ class Stack {
|
|
|
57445
57394
|
serverName: this.config.node.name,
|
|
57446
57395
|
hostname: this.config.node.hostname,
|
|
57447
57396
|
packageName: "@ebowwa/stack",
|
|
57448
|
-
version: "0.
|
|
57397
|
+
version: "0.4.0"
|
|
57449
57398
|
}
|
|
57450
57399
|
});
|
|
57451
57400
|
this.client = new GLMClient;
|
|
@@ -57481,22 +57430,6 @@ class Stack {
|
|
|
57481
57430
|
this.state.channels.telegram = true;
|
|
57482
57431
|
console.log("[Stack] Telegram registered");
|
|
57483
57432
|
}
|
|
57484
|
-
async initializeNodeAgent() {
|
|
57485
|
-
console.log("[Stack] Initializing Node Agent services...");
|
|
57486
|
-
try {
|
|
57487
|
-
const nodeAgent = await import("@ebowwa/node-agent/lib");
|
|
57488
|
-
this.ralphService = new nodeAgent.RalphService;
|
|
57489
|
-
this.gitService = new nodeAgent.GitService;
|
|
57490
|
-
this.consoleLogger = new nodeAgent.ConsoleLoggerService;
|
|
57491
|
-
await nodeAgent.initializeStateService();
|
|
57492
|
-
console.log("[Stack] State service initialized");
|
|
57493
|
-
this.state.nodeAgent.enabled = true;
|
|
57494
|
-
console.log("[Stack] Node Agent services ready (Ralph/Git DISABLED)");
|
|
57495
|
-
} catch (error) {
|
|
57496
|
-
console.warn("[Stack] Node Agent initialization failed (non-critical):", error);
|
|
57497
|
-
console.warn("[Stack] Continuing without Node Agent services");
|
|
57498
|
-
}
|
|
57499
|
-
}
|
|
57500
57433
|
async handleMessage(routed) {
|
|
57501
57434
|
const { message, channelId } = routed;
|
|
57502
57435
|
const channel = channelId.platform;
|
|
@@ -57558,7 +57491,6 @@ class Stack {
|
|
|
57558
57491
|
## Capabilities
|
|
57559
57492
|
- Cross-channel memory (shared context between channels)
|
|
57560
57493
|
- Tool execution via MCP
|
|
57561
|
-
- Node monitoring and management
|
|
57562
57494
|
|
|
57563
57495
|
## Commands
|
|
57564
57496
|
- \`/status\` \u2014 Node status
|
|
@@ -57567,14 +57499,12 @@ class Stack {
|
|
|
57567
57499
|
## Info
|
|
57568
57500
|
- Node: ${this.config.node.name}
|
|
57569
57501
|
- Channels: ${channelList}
|
|
57570
|
-
- Node Agent: ${this.state.nodeAgent.enabled ? "ready (Ralph/Git disabled)" : "off"}
|
|
57571
57502
|
- API: :${this.config.api?.port ?? 8911}`;
|
|
57572
57503
|
}
|
|
57573
57504
|
getStatus() {
|
|
57574
57505
|
const lines = [
|
|
57575
57506
|
`**${this.config.node.name} Status**`,
|
|
57576
57507
|
`Channels: SSH=${this.state.channels.ssh}, Telegram=${this.state.channels.telegram}`,
|
|
57577
|
-
`Node Agent: ${this.state.nodeAgent.enabled ? "ready (Ralph/Git disabled)" : "off"}`,
|
|
57578
57508
|
`Uptime: ${Math.floor((Date.now() - this.state.started.getTime()) / 1000)}s`
|
|
57579
57509
|
];
|
|
57580
57510
|
return lines.join(`
|
|
@@ -57603,7 +57533,6 @@ class Stack {
|
|
|
57603
57533
|
return Response.json({
|
|
57604
57534
|
node: this.config.node.name,
|
|
57605
57535
|
channels: this.state.channels,
|
|
57606
|
-
nodeAgent: this.state.nodeAgent,
|
|
57607
57536
|
uptime: Math.floor((Date.now() - this.state.started.getTime()) / 1000)
|
|
57608
57537
|
}, { headers: corsHeaders });
|
|
57609
57538
|
}
|
|
@@ -57618,7 +57547,6 @@ class Stack {
|
|
|
57618
57547
|
async start() {
|
|
57619
57548
|
console.log(`[Stack] Starting ${this.config.node.name}...`);
|
|
57620
57549
|
this.abortController = new AbortController;
|
|
57621
|
-
await this.initializeNodeAgent();
|
|
57622
57550
|
await this.registerSSH();
|
|
57623
57551
|
await this.registerTelegram();
|
|
57624
57552
|
this.router.setHandler((routed) => this.handleMessage(routed));
|
|
@@ -57634,7 +57562,6 @@ class Stack {
|
|
|
57634
57562
|
if (this.state.api.enabled) {
|
|
57635
57563
|
console.log(` - API: :${this.state.api.port}`);
|
|
57636
57564
|
}
|
|
57637
|
-
console.log(" - Node Agent: ready (Ralph/Git disabled)");
|
|
57638
57565
|
console.log(" - Commands: /status, /memory <cmd>");
|
|
57639
57566
|
await new Promise(() => {});
|
|
57640
57567
|
}
|
|
@@ -57670,8 +57597,7 @@ async function main() {
|
|
|
57670
57597
|
node: {
|
|
57671
57598
|
name: process.env.NODE_NAME || "stack",
|
|
57672
57599
|
hostname: process.env.HOSTNAME || "localhost"
|
|
57673
|
-
}
|
|
57674
|
-
enableNodeAgent: process.env.ENABLE_NODE_AGENT !== "false"
|
|
57600
|
+
}
|
|
57675
57601
|
};
|
|
57676
57602
|
const stack = new Stack(config);
|
|
57677
57603
|
process.on("SIGINT", async () => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ebowwa/stack",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Cross-channel AI stack
|
|
3
|
+
"version": "0.4.1",
|
|
4
|
+
"description": "Cross-channel AI stack (SSH + Telegram + GLM)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"scripts": {
|
|
17
17
|
"dev": "bun --hot run src/index.ts",
|
|
18
18
|
"start": "bun run src/index.ts",
|
|
19
|
-
"build": "bun build src/index.ts --target bun --outdir ./dist
|
|
19
|
+
"build": "bun build src/index.ts --target bun --outdir ./dist"
|
|
20
20
|
},
|
|
21
21
|
"keywords": [
|
|
22
22
|
"stack",
|
|
@@ -25,9 +25,7 @@
|
|
|
25
25
|
"ssh",
|
|
26
26
|
"ai",
|
|
27
27
|
"cross-channel",
|
|
28
|
-
"memory"
|
|
29
|
-
"ralph",
|
|
30
|
-
"node-agent"
|
|
28
|
+
"memory"
|
|
31
29
|
],
|
|
32
30
|
"author": "Ebowwa Labs <labs@ebowwa.com>",
|
|
33
31
|
"license": "MIT",
|
|
@@ -42,10 +40,16 @@
|
|
|
42
40
|
"@ebowwa/channel-ssh": "^2.1.1",
|
|
43
41
|
"@ebowwa/channel-telegram": "^1.14.2",
|
|
44
42
|
"@ebowwa/channel-types": "^0.2.1",
|
|
45
|
-
"@ebowwa/codespaces-types": "^1.6.1"
|
|
46
|
-
"@ebowwa/node-agent": "^0.6.5"
|
|
43
|
+
"@ebowwa/codespaces-types": "^1.6.1"
|
|
47
44
|
},
|
|
48
45
|
"devDependencies": {
|
|
49
46
|
"@types/bun": "latest"
|
|
47
|
+
},
|
|
48
|
+
"ownership": {
|
|
49
|
+
"domain": "state",
|
|
50
|
+
"responsibilities": [
|
|
51
|
+
"stack-operations",
|
|
52
|
+
"execution-context"
|
|
53
|
+
]
|
|
50
54
|
}
|
|
51
55
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
/**
|
|
3
|
-
* @ebowwa/stack - Cross-Channel AI Stack
|
|
3
|
+
* @ebowwa/stack - Cross-Channel AI Stack
|
|
4
4
|
*
|
|
5
5
|
* Features:
|
|
6
|
-
* -
|
|
6
|
+
* - Cross-channel communication (SSH + Telegram)
|
|
7
7
|
* - Cross-channel memory with permission controls
|
|
8
|
-
* - AI-powered message handling
|
|
9
|
-
* -
|
|
8
|
+
* - AI-powered message handling (GLM)
|
|
9
|
+
* - HTTP API for status/health
|
|
10
10
|
*
|
|
11
11
|
* Architecture:
|
|
12
12
|
* ┌──────────────────────────────────────────────────────────────┐
|
|
@@ -23,13 +23,10 @@
|
|
|
23
23
|
* │ │ (Cross-Context) │ │
|
|
24
24
|
* │ └─────────┬─────────┘ │
|
|
25
25
|
* │ │ │
|
|
26
|
-
* │
|
|
27
|
-
* │
|
|
28
|
-
* │
|
|
29
|
-
* │
|
|
30
|
-
* │ │ (GLM) │ │ (Ralph/Git/...) │ │
|
|
31
|
-
* │ └───────────────┘ │ [DISABLED] │ │
|
|
32
|
-
* │ └──────────────────┘ │
|
|
26
|
+
* │ ┌─────────▼─────────┐ │
|
|
27
|
+
* │ │ AI Brain │ │
|
|
28
|
+
* │ │ (GLM) │ │
|
|
29
|
+
* │ └───────────────────┘ │
|
|
33
30
|
* └──────────────────────────────────────────────────────────────┘
|
|
34
31
|
*/
|
|
35
32
|
|
|
@@ -38,11 +35,6 @@ import type { ChannelConnector, ChannelMessage, ChannelResponse, ChannelId } fro
|
|
|
38
35
|
import { GLMClient } from "@ebowwa/ai";
|
|
39
36
|
import { ToolExecutor, BUILTIN_TOOLS } from "@ebowwa/ai/tools";
|
|
40
37
|
|
|
41
|
-
// Node Agent types (lazy import to avoid bundling issues)
|
|
42
|
-
type RalphServiceType = InstanceType<typeof import("@ebowwa/node-agent/lib").RalphService>;
|
|
43
|
-
type GitServiceType = InstanceType<typeof import("@ebowwa/node-agent/lib").GitService>;
|
|
44
|
-
type ConsoleLoggerServiceType = InstanceType<typeof import("@ebowwa/node-agent/lib").ConsoleLoggerService>;
|
|
45
|
-
|
|
46
38
|
// ============================================================
|
|
47
39
|
// Types
|
|
48
40
|
// ============================================================
|
|
@@ -74,8 +66,6 @@ export interface StackConfig {
|
|
|
74
66
|
name: string;
|
|
75
67
|
hostname?: string;
|
|
76
68
|
};
|
|
77
|
-
/** Enable Node Agent features (Ralph, Git, etc.) */
|
|
78
|
-
enableNodeAgent?: boolean;
|
|
79
69
|
}
|
|
80
70
|
|
|
81
71
|
export interface StackState {
|
|
@@ -88,9 +78,6 @@ export interface StackState {
|
|
|
88
78
|
enabled: boolean;
|
|
89
79
|
port?: number;
|
|
90
80
|
};
|
|
91
|
-
nodeAgent: {
|
|
92
|
-
enabled: boolean;
|
|
93
|
-
};
|
|
94
81
|
}
|
|
95
82
|
|
|
96
83
|
// ============================================================
|
|
@@ -107,11 +94,6 @@ export class Stack {
|
|
|
107
94
|
private channels: Map<string, ChannelConnector> = new Map();
|
|
108
95
|
private abortController: AbortController | null = null;
|
|
109
96
|
|
|
110
|
-
// Node Agent services (lazy loaded to avoid bundling issues)
|
|
111
|
-
private ralphService: RalphServiceType | null = null;
|
|
112
|
-
private gitService: GitServiceType | null = null;
|
|
113
|
-
private consoleLogger: ConsoleLoggerServiceType | null = null;
|
|
114
|
-
|
|
115
97
|
constructor(config: StackConfig) {
|
|
116
98
|
this.config = {
|
|
117
99
|
...config,
|
|
@@ -124,10 +106,9 @@ export class Stack {
|
|
|
124
106
|
started: new Date(),
|
|
125
107
|
channels: { ssh: false, telegram: false },
|
|
126
108
|
api: { enabled: !!this.config.api, port: this.config.api?.port },
|
|
127
|
-
nodeAgent: { enabled: false },
|
|
128
109
|
};
|
|
129
110
|
|
|
130
|
-
// Build memory channels dynamically
|
|
111
|
+
// Build memory channels dynamically from enabled channels
|
|
131
112
|
const memoryChannels: Record<string, { memoryFile: string; maxMessages: number }> = {};
|
|
132
113
|
const permissions: Record<string, { canRead: string[] }> = {};
|
|
133
114
|
const enabledChannels: string[] = [];
|
|
@@ -155,14 +136,12 @@ export class Stack {
|
|
|
155
136
|
serverName: this.config.node.name,
|
|
156
137
|
hostname: this.config.node.hostname,
|
|
157
138
|
packageName: "@ebowwa/stack",
|
|
158
|
-
version: "0.
|
|
139
|
+
version: "0.4.0",
|
|
159
140
|
},
|
|
160
141
|
});
|
|
161
142
|
|
|
162
143
|
this.client = new GLMClient();
|
|
163
144
|
this.executor = new ToolExecutor(this.client, [...BUILTIN_TOOLS]);
|
|
164
|
-
|
|
165
|
-
// Node Agent services initialized lazily in initializeNodeAgent()
|
|
166
145
|
}
|
|
167
146
|
|
|
168
147
|
// ============================================================
|
|
@@ -202,38 +181,6 @@ export class Stack {
|
|
|
202
181
|
console.log("[Stack] Telegram registered");
|
|
203
182
|
}
|
|
204
183
|
|
|
205
|
-
// ============================================================
|
|
206
|
-
// Node Agent Initialization
|
|
207
|
-
// ============================================================
|
|
208
|
-
|
|
209
|
-
private async initializeNodeAgent(): Promise<void> {
|
|
210
|
-
console.log("[Stack] Initializing Node Agent services...");
|
|
211
|
-
|
|
212
|
-
// Lazy import to avoid bundling issues with node-agent
|
|
213
|
-
try {
|
|
214
|
-
const nodeAgent = await import("@ebowwa/node-agent/lib");
|
|
215
|
-
|
|
216
|
-
// Initialize services (features disabled for now)
|
|
217
|
-
this.ralphService = new nodeAgent.RalphService();
|
|
218
|
-
this.gitService = new nodeAgent.GitService();
|
|
219
|
-
this.consoleLogger = new nodeAgent.ConsoleLoggerService();
|
|
220
|
-
|
|
221
|
-
// Initialize state service
|
|
222
|
-
await nodeAgent.initializeStateService();
|
|
223
|
-
console.log("[Stack] State service initialized");
|
|
224
|
-
|
|
225
|
-
// TODO: Enable Ralph/Git when ready
|
|
226
|
-
// this.ralphService?.startMonitoring();
|
|
227
|
-
// this.gitService?.initialize();
|
|
228
|
-
|
|
229
|
-
this.state.nodeAgent.enabled = true;
|
|
230
|
-
console.log("[Stack] Node Agent services ready (Ralph/Git DISABLED)");
|
|
231
|
-
} catch (error) {
|
|
232
|
-
console.warn("[Stack] Node Agent initialization failed (non-critical):", error);
|
|
233
|
-
console.warn("[Stack] Continuing without Node Agent services");
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
184
|
// ============================================================
|
|
238
185
|
// Message Handler
|
|
239
186
|
// ============================================================
|
|
@@ -277,15 +224,6 @@ export class Stack {
|
|
|
277
224
|
};
|
|
278
225
|
}
|
|
279
226
|
|
|
280
|
-
// Ralph commands (DISABLED for now)
|
|
281
|
-
// if (text.startsWith("/ralph")) {
|
|
282
|
-
// stopTyping();
|
|
283
|
-
// return {
|
|
284
|
-
// content: { text: await this.handleRalphCommand(text) },
|
|
285
|
-
// replyTo: { messageId: message.messageId, channelId: message.channelId },
|
|
286
|
-
// };
|
|
287
|
-
// }
|
|
288
|
-
|
|
289
227
|
// Add to memory
|
|
290
228
|
this.memory.addMessage(channel, { role: "user", content: text });
|
|
291
229
|
|
|
@@ -334,7 +272,6 @@ export class Stack {
|
|
|
334
272
|
## Capabilities
|
|
335
273
|
- Cross-channel memory (shared context between channels)
|
|
336
274
|
- Tool execution via MCP
|
|
337
|
-
- Node monitoring and management
|
|
338
275
|
|
|
339
276
|
## Commands
|
|
340
277
|
- \`/status\` — Node status
|
|
@@ -343,7 +280,6 @@ export class Stack {
|
|
|
343
280
|
## Info
|
|
344
281
|
- Node: ${this.config.node.name}
|
|
345
282
|
- Channels: ${channelList}
|
|
346
|
-
- Node Agent: ${this.state.nodeAgent.enabled ? "ready (Ralph/Git disabled)" : "off"}
|
|
347
283
|
- API: :${this.config.api?.port ?? 8911}`;
|
|
348
284
|
}
|
|
349
285
|
|
|
@@ -351,7 +287,6 @@ export class Stack {
|
|
|
351
287
|
const lines = [
|
|
352
288
|
`**${this.config.node.name} Status**`,
|
|
353
289
|
`Channels: SSH=${this.state.channels.ssh}, Telegram=${this.state.channels.telegram}`,
|
|
354
|
-
`Node Agent: ${this.state.nodeAgent.enabled ? "ready (Ralph/Git disabled)" : "off"}`,
|
|
355
290
|
`Uptime: ${Math.floor((Date.now() - this.state.started.getTime()) / 1000)}s`,
|
|
356
291
|
];
|
|
357
292
|
return lines.join("\n");
|
|
@@ -384,15 +319,16 @@ export class Stack {
|
|
|
384
319
|
return new Response(null, { headers: corsHeaders });
|
|
385
320
|
}
|
|
386
321
|
|
|
322
|
+
// Stack status
|
|
387
323
|
if (path === "/api/status" && req.method === "GET") {
|
|
388
324
|
return Response.json({
|
|
389
325
|
node: this.config.node.name,
|
|
390
326
|
channels: this.state.channels,
|
|
391
|
-
nodeAgent: this.state.nodeAgent,
|
|
392
327
|
uptime: Math.floor((Date.now() - this.state.started.getTime()) / 1000),
|
|
393
328
|
}, { headers: corsHeaders });
|
|
394
329
|
}
|
|
395
330
|
|
|
331
|
+
// Health check
|
|
396
332
|
if (path === "/health") {
|
|
397
333
|
return Response.json({ status: "ok" }, { headers: corsHeaders });
|
|
398
334
|
}
|
|
@@ -413,9 +349,6 @@ export class Stack {
|
|
|
413
349
|
|
|
414
350
|
this.abortController = new AbortController();
|
|
415
351
|
|
|
416
|
-
// Initialize Node Agent (services ready but features disabled)
|
|
417
|
-
await this.initializeNodeAgent();
|
|
418
|
-
|
|
419
352
|
// Register channels
|
|
420
353
|
await this.registerSSH();
|
|
421
354
|
await this.registerTelegram();
|
|
@@ -435,7 +368,6 @@ export class Stack {
|
|
|
435
368
|
if (this.state.api.enabled) {
|
|
436
369
|
console.log(` - API: :${this.state.api.port}`);
|
|
437
370
|
}
|
|
438
|
-
console.log(" - Node Agent: ready (Ralph/Git disabled)");
|
|
439
371
|
console.log(" - Commands: /status, /memory <cmd>");
|
|
440
372
|
|
|
441
373
|
await new Promise(() => {});
|
|
@@ -481,7 +413,6 @@ async function main() {
|
|
|
481
413
|
name: process.env.NODE_NAME || "stack",
|
|
482
414
|
hostname: process.env.HOSTNAME || "localhost",
|
|
483
415
|
},
|
|
484
|
-
enableNodeAgent: process.env.ENABLE_NODE_AGENT !== "false",
|
|
485
416
|
};
|
|
486
417
|
|
|
487
418
|
const stack = new Stack(config);
|