@drakonkat/ai-helper 1.0.2 → 1.1.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/CHANGELOG.md +17 -1
- package/README.md +2 -1
- package/package.json +13 -5
- package/src/config.js +13 -5
- package/src/index.js +1 -2
- package/src/manager.js +17 -9
- package/src/utils/process.js +72 -43
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,23 @@ All notable changes to **`ai-helper` (`aih`)** are documented in this file.
|
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
+
## [1.1.0] - 2026-08-27
|
|
8
|
+
|
|
9
|
+
### 🚀 New Features
|
|
10
|
+
- **Headroom Service Integration**: Added full background service management, live status, logs, and dashboard launching for `headroom` (`headroom proxy` on port `8787` with dashboard at `http://localhost:8787/dashboard`).
|
|
11
|
+
- **Cross-Platform Auto-Discovery**: Automatic discovery of externally launched `headroom` proxy processes via OS process table queries and TCP port 8787 listeners.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## [1.0.4] - 2026-08-27
|
|
16
|
+
|
|
17
|
+
### 🐛 Bug Fixes
|
|
18
|
+
- **Self Process CLI Exclusion**: Exclude current CLI process (`process.pid`) and `aih` CLI command patterns from OS process auto-discovery, preventing false-positive "already running" statuses during `aih start <service>`.
|
|
19
|
+
- **Precise Process Matching**: Refine `pxpipe-proxy` matching patterns so general CLI arguments are not mistaken for the active service daemon.
|
|
20
|
+
- **Post-Start Verification**: Verify actual service liveness after the startup grace period in `startService`, reporting startup failures accurately instead of declaring dead processes as running.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
7
24
|
## [1.0.2] - 2026-08-19
|
|
8
25
|
|
|
9
26
|
### 🐛 Bug Fixes
|
|
@@ -31,4 +48,3 @@ All notable changes to **`ai-helper` (`aih`)** are documented in this file.
|
|
|
31
48
|
- **Unified Live Log Streaming**: Real-time log capture and streaming with `aih logs <service> -f`.
|
|
32
49
|
- **Programmatic JSON API**: Added `--json` flag for IDE, agent, and pipeline integration.
|
|
33
50
|
- **Cross-Runtime & NPX Ready**: Universal Node.js (>=18) and Bun support.
|
|
34
|
-
|
package/README.md
CHANGED
|
@@ -34,6 +34,7 @@ When building, testing, and collaborating with local AI agents, coding assistant
|
|
|
34
34
|
1. **`pxpipe`**: LLM & MCP protocol reverse proxy bridge (`npx pxpipe-proxy`).
|
|
35
35
|
2. **`ocx`**: OpenCode interpreter and execution daemon (`ocx start`).
|
|
36
36
|
3. **`agentmemory`**: Persistent long-term agent memory server (`npx @agentmemory/agentmemory`).
|
|
37
|
+
4. **`headroom`**: LLM context optimization & compression proxy (`headroom proxy`).
|
|
37
38
|
|
|
38
39
|
Manually opening separate terminal tabs for each service is messy, clutters your workspace, and easily leads to orphaned background processes and blocked ports.
|
|
39
40
|
|
|
@@ -82,6 +83,7 @@ bun add -g @drakonkat/ai-helper
|
|
|
82
83
|
| **`pxpipe`** | `npx pxpipe-proxy` | [`http://localhost:47821`](http://localhost:47821) | AI LLM & MCP protocol reverse proxy bridge |
|
|
83
84
|
| **`ocx`** | `ocx start` | [`http://localhost:10100`](http://localhost:10100) | OpenCode interpreter execution daemon |
|
|
84
85
|
| **`agentmemory`** | `npx @agentmemory/agentmemory` | [`http://localhost:3113`](http://localhost:3113) | Persistent agent long-term memory server & viewer |
|
|
86
|
+
| **`headroom`** | `headroom proxy` | [`http://localhost:8787/dashboard`](http://localhost:8787/dashboard) | Context optimization & LLM compression proxy |
|
|
85
87
|
|
|
86
88
|
---
|
|
87
89
|
|
|
@@ -284,4 +286,3 @@ bun run build
|
|
|
284
286
|
## 📄 License
|
|
285
287
|
|
|
286
288
|
Distributed under the **MIT License**. See [LICENSE](LICENSE) for more information.
|
|
287
|
-
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drakonkat/ai-helper",
|
|
3
|
-
"version": "1.0
|
|
4
|
-
"description": "Zero-config background service manager, auto-discovery daemon & dashboard launcher for AI agent ecosystems (pxpipe, ocx, agentmemory)",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "Zero-config background service manager, auto-discovery daemon & dashboard launcher for AI agent ecosystems (pxpipe, ocx, agentmemory, headroom)",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"module": "src/index.js",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"bin": {
|
|
9
|
-
"aih": "
|
|
10
|
-
"ai-helper": "
|
|
9
|
+
"aih": "bin/cli.js",
|
|
10
|
+
"ai-helper": "bin/cli.js"
|
|
11
11
|
},
|
|
12
12
|
"files": [
|
|
13
13
|
"bin",
|
|
@@ -23,6 +23,14 @@
|
|
|
23
23
|
"publishConfig": {
|
|
24
24
|
"access": "public"
|
|
25
25
|
},
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "git+https://github.com/drakonkat/ai-helper.git"
|
|
29
|
+
},
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/drakonkat/ai-helper/issues"
|
|
32
|
+
},
|
|
33
|
+
"homepage": "https://github.com/drakonkat/ai-helper#readme",
|
|
26
34
|
"scripts": {
|
|
27
35
|
"start": "node ./bin/cli.js",
|
|
28
36
|
"dev": "node ./bin/cli.js",
|
|
@@ -37,6 +45,7 @@
|
|
|
37
45
|
"pxpipe",
|
|
38
46
|
"ocx",
|
|
39
47
|
"agentmemory",
|
|
48
|
+
"headroom",
|
|
40
49
|
"mcp",
|
|
41
50
|
"npx",
|
|
42
51
|
"service-manager",
|
|
@@ -46,4 +55,3 @@
|
|
|
46
55
|
"author": "Mauro",
|
|
47
56
|
"license": "MIT"
|
|
48
57
|
}
|
|
49
|
-
|
package/src/config.js
CHANGED
|
@@ -30,9 +30,18 @@ export const SERVICES = {
|
|
|
30
30
|
command: "npx @agentmemory/agentmemory",
|
|
31
31
|
stopCommand: "npx @agentmemory/agentmemory stop --force",
|
|
32
32
|
description: "Long-term persistent agent memory service (@agentmemory/agentmemory)",
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
defaultPort: 3113,
|
|
34
|
+
defaultUrl: "http://localhost:3113",
|
|
35
|
+
ports: [3111, 3112, 3113, 49134],
|
|
36
|
+
},
|
|
37
|
+
headroom: {
|
|
38
|
+
id: "headroom",
|
|
39
|
+
name: "headroom",
|
|
40
|
+
command: "headroom proxy",
|
|
41
|
+
description: "Context optimization & LLM proxy (headroom proxy)",
|
|
42
|
+
defaultPort: 8787,
|
|
43
|
+
defaultUrl: "http://localhost:8787/dashboard",
|
|
44
|
+
ports: [8787],
|
|
36
45
|
},
|
|
37
46
|
};
|
|
38
47
|
|
|
@@ -40,5 +49,4 @@ export const SERVICE_IDS = Object.keys(SERVICES);
|
|
|
40
49
|
|
|
41
50
|
export const APP_NAME = "ai-helper";
|
|
42
51
|
export const CLI_NAME = "aih";
|
|
43
|
-
export const VERSION = "1.0
|
|
44
|
-
|
|
52
|
+
export const VERSION = "1.1.0";
|
package/src/index.js
CHANGED
|
@@ -25,7 +25,7 @@ function printHelp() {
|
|
|
25
25
|
${bold("COMMANDS:")}
|
|
26
26
|
${yellow("status")}, ${yellow("ps")} Show status, PID, uptime, and web dashboard URLs
|
|
27
27
|
${yellow("open")}, ${yellow("dash")} [services...] Open web dashboard(s) directly in your default browser
|
|
28
|
-
${yellow("start")}, ${yellow("up")} [services...] Start all or specified services (pxpipe, ocx, agentmemory)
|
|
28
|
+
${yellow("start")}, ${yellow("up")} [services...] Start all or specified services (pxpipe, ocx, agentmemory, headroom)
|
|
29
29
|
${yellow("stop")}, ${yellow("down")} [services...] Stop all or specified services
|
|
30
30
|
${yellow("restart")} [services...] Restart all or specified services
|
|
31
31
|
${yellow("logs")} <service> [-n 50] [-f] View or stream live logs for a service
|
|
@@ -323,4 +323,3 @@ main().catch(err => {
|
|
|
323
323
|
console.error(red(`[aih] Fatal error: ${err?.message || err}`));
|
|
324
324
|
process.exit(1);
|
|
325
325
|
});
|
|
326
|
-
|
package/src/manager.js
CHANGED
|
@@ -234,19 +234,28 @@ export class ServiceManager {
|
|
|
234
234
|
startedAt: new Date().toISOString(),
|
|
235
235
|
url: def.defaultUrl,
|
|
236
236
|
};
|
|
237
|
-
|
|
237
|
+
this.saveState(state);
|
|
238
|
+
|
|
239
|
+
// Wait a moment for background boot
|
|
240
|
+
await sleep(2000);
|
|
238
241
|
|
|
239
|
-
|
|
240
|
-
await
|
|
242
|
+
// Re-sync with OS
|
|
243
|
+
const updatedState = await this.syncState();
|
|
244
|
+
const updatedSvc = updatedState.services[serviceId];
|
|
241
245
|
|
|
242
|
-
|
|
243
|
-
|
|
246
|
+
if (!updatedSvc || updatedSvc.status !== "running" || !updatedSvc.pid || !isPidRunning(updatedSvc.pid)) {
|
|
247
|
+
return {
|
|
248
|
+
success: false,
|
|
249
|
+
message: `Service '${serviceId}' failed to start or exited immediately. Check logs with 'aih logs ${serviceId}'`,
|
|
250
|
+
pid,
|
|
251
|
+
};
|
|
252
|
+
}
|
|
244
253
|
|
|
245
254
|
return {
|
|
246
255
|
success: true,
|
|
247
|
-
message: `Service '${serviceId}' started successfully (PID: ${pid})`,
|
|
248
|
-
pid,
|
|
249
|
-
url: def.defaultUrl,
|
|
256
|
+
message: `Service '${serviceId}' started successfully (PID: ${updatedSvc.pid})`,
|
|
257
|
+
pid: updatedSvc.pid,
|
|
258
|
+
url: updatedSvc.url || def.defaultUrl,
|
|
250
259
|
};
|
|
251
260
|
}
|
|
252
261
|
|
|
@@ -400,4 +409,3 @@ export class ServiceManager {
|
|
|
400
409
|
}
|
|
401
410
|
|
|
402
411
|
export const manager = new ServiceManager();
|
|
403
|
-
|
package/src/utils/process.js
CHANGED
|
@@ -241,15 +241,17 @@ export function spawnDetachedProcess(command, logFilePath, options) {
|
|
|
241
241
|
*/
|
|
242
242
|
export async function discoverRunningProcesses() {
|
|
243
243
|
const discovered = {};
|
|
244
|
+
const currentPid = process.pid;
|
|
244
245
|
|
|
245
246
|
if (process.platform === "win32") {
|
|
246
247
|
try {
|
|
247
248
|
const script = `
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
($_.CommandLine -
|
|
252
|
-
|
|
249
|
+
$procs = Get-CimInstance Win32_Process | Where-Object {
|
|
250
|
+
$_.ProcessId -ne ${currentPid} -and
|
|
251
|
+
$_.CommandLine -and
|
|
252
|
+
($_.CommandLine -match 'pxpipe-proxy|ocx|agentmemory|iii|headroom') -and
|
|
253
|
+
($_.CommandLine -notmatch 'ai-helper|\\baih(\\.exe)?\\b|bin\\\\cli\\.js|Get-CimInstance|Where-Object|Select-Object')
|
|
254
|
+
} | Select-Object ProcessId, ParentProcessId, Name, CommandLine, CreationDate
|
|
253
255
|
|
|
254
256
|
$ports = Get-NetTCPConnection -State Listen -ErrorAction SilentlyContinue | Select-Object LocalPort, OwningProcess
|
|
255
257
|
|
|
@@ -280,7 +282,12 @@ export async function discoverRunningProcesses() {
|
|
|
280
282
|
for (const item of procList) {
|
|
281
283
|
const cmd = item.CommandLine || "";
|
|
282
284
|
const pid = item.ProcessId;
|
|
283
|
-
if (!pid || !isPidRunning(pid)) continue;
|
|
285
|
+
if (!pid || pid === currentPid || !isPidRunning(pid)) continue;
|
|
286
|
+
|
|
287
|
+
// Skip any ai-helper / aih CLI executions
|
|
288
|
+
if (cmd.includes("bin/cli.js") || cmd.includes("bin\\cli.js") || /\baih(\.exe)?\b/i.test(cmd)) {
|
|
289
|
+
continue;
|
|
290
|
+
}
|
|
284
291
|
|
|
285
292
|
let startedAt;
|
|
286
293
|
if (item.CreationDate) {
|
|
@@ -298,7 +305,7 @@ export async function discoverRunningProcesses() {
|
|
|
298
305
|
const ports = pidToPorts[pid] || [];
|
|
299
306
|
|
|
300
307
|
// 1. pxpipe
|
|
301
|
-
if (cmd.includes("pxpipe-proxy")
|
|
308
|
+
if (cmd.includes("pxpipe-proxy")) {
|
|
302
309
|
if (!discovered.pxpipe || (item.Name && item.Name.toLowerCase() === "node.exe" && cmd.includes("cli.js"))) {
|
|
303
310
|
const webPort = ports.find(p => p > 1000 && p < 65000) || (discovered.pxpipe?.port);
|
|
304
311
|
discovered.pxpipe = {
|
|
@@ -312,7 +319,7 @@ export async function discoverRunningProcesses() {
|
|
|
312
319
|
}
|
|
313
320
|
|
|
314
321
|
// 2. ocx
|
|
315
|
-
if (cmd.includes("ocx.mjs") || cmd.includes("opencodex") || cmd.includes("ocx start")) {
|
|
322
|
+
if (cmd.includes("ocx.mjs") || cmd.includes("opencodex") || (cmd.includes("ocx start") && !cmd.includes("aih "))) {
|
|
316
323
|
const webPort = ports.find(p => p === 10100 || (p > 1000 && p < 65000));
|
|
317
324
|
if (!discovered.ocx || cmd.includes("ocx.mjs start")) {
|
|
318
325
|
discovered.ocx = {
|
|
@@ -335,35 +342,52 @@ export async function discoverRunningProcesses() {
|
|
|
335
342
|
cmd.includes("agentmemory/dist/cli.mjs") ||
|
|
336
343
|
cmd.includes("iii-config.yaml") ||
|
|
337
344
|
cmd.includes("iii.exe") ||
|
|
338
|
-
(cmd.includes("agentmemory") && !cmd.includes("mcp")))
|
|
345
|
+
(cmd.includes("agentmemory") && !cmd.includes("mcp") && !cmd.includes("aih ")))
|
|
339
346
|
) {
|
|
340
347
|
const webPort = ports.find(p => p === 3113 || p === 43210 || (p > 1000 && p < 65000));
|
|
341
|
-
|
|
342
|
-
|
|
348
|
+
if (!discovered.agentmemory || cmd.includes("agentmemory/agentmemory") || cmd.includes("dist\\cli.mjs")) {
|
|
349
|
+
discovered.agentmemory = {
|
|
350
|
+
pid,
|
|
351
|
+
command: cmd,
|
|
352
|
+
startedAt,
|
|
353
|
+
port: webPort || 3113,
|
|
354
|
+
url: `http://localhost:${webPort || 3113}`,
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
// 4. headroom
|
|
360
|
+
if (cmd.includes("headroom proxy") || (cmd.includes("headroom") && !cmd.includes("aih "))) {
|
|
361
|
+
const webPort = ports.find(p => p === 8787 || (p > 1000 && p < 65000));
|
|
362
|
+
if (!discovered.headroom || cmd.includes("headroom proxy")) {
|
|
363
|
+
discovered.headroom = {
|
|
343
364
|
pid,
|
|
344
365
|
command: cmd,
|
|
345
366
|
startedAt,
|
|
346
|
-
port: webPort ||
|
|
347
|
-
url: `http://localhost:${webPort ||
|
|
367
|
+
port: webPort || 8787,
|
|
368
|
+
url: `http://localhost:${webPort || 8787}/dashboard`,
|
|
348
369
|
};
|
|
349
370
|
}
|
|
350
371
|
}
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
for (const p of procList) {
|
|
375
|
+
const ports = pidToPorts[p.ProcessId] || [];
|
|
376
|
+
if (ports.length > 0) {
|
|
377
|
+
if (ports.includes(47821) && discovered.pxpipe) {
|
|
378
|
+
discovered.pxpipe.url = "http://localhost:47821";
|
|
379
|
+
}
|
|
380
|
+
if (ports.includes(10100) && discovered.ocx) {
|
|
381
|
+
discovered.ocx.url = "http://localhost:10100";
|
|
382
|
+
}
|
|
383
|
+
if (ports.includes(3113) && discovered.agentmemory) {
|
|
384
|
+
discovered.agentmemory.url = "http://localhost:3113";
|
|
385
|
+
}
|
|
386
|
+
if (ports.includes(8787) && discovered.headroom) {
|
|
387
|
+
discovered.headroom.url = "http://localhost:8787/dashboard";
|
|
361
388
|
}
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
}
|
|
389
|
+
}
|
|
390
|
+
}
|
|
367
391
|
} catch {}
|
|
368
392
|
} else {
|
|
369
393
|
try {
|
|
@@ -372,34 +396,39 @@ export async function discoverRunningProcesses() {
|
|
|
372
396
|
|
|
373
397
|
for (const line of lines) {
|
|
374
398
|
const trimmed = line.trim();
|
|
375
|
-
if (!trimmed || trimmed.includes("ps -eo") || trimmed.includes("ai-helper")) continue;
|
|
399
|
+
if (!trimmed || trimmed.includes("ps -eo") || trimmed.includes("ai-helper") || /\baih\b/.test(trimmed)) continue;
|
|
376
400
|
|
|
377
401
|
const parts = trimmed.split(/\s+/);
|
|
378
402
|
const pid = parseInt(parts[0], 10);
|
|
379
403
|
const cmd = parts.slice(1).join(" ");
|
|
380
|
-
if (!pid || !isPidRunning(pid)) continue;
|
|
404
|
+
if (!pid || pid === currentPid || !isPidRunning(pid)) continue;
|
|
405
|
+
|
|
406
|
+
if (cmd.includes("bin/cli.js") || cmd.includes("bin/aih")) continue;
|
|
381
407
|
|
|
382
|
-
if (cmd.includes("pxpipe-proxy")
|
|
408
|
+
if (cmd.includes("pxpipe-proxy")) {
|
|
383
409
|
if (!discovered.pxpipe) discovered.pxpipe = { pid, command: cmd, url: "http://localhost:47821" };
|
|
384
410
|
}
|
|
385
411
|
if (cmd.includes("ocx start") || cmd.includes("ocx.mjs") || cmd.includes("opencodex")) {
|
|
386
412
|
if (!discovered.ocx) discovered.ocx = { pid, command: cmd, url: "http://localhost:10100" };
|
|
387
413
|
}
|
|
388
414
|
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
415
|
+
const isMcpShim = cmd.includes("agentmemory-mcp") || cmd.includes("@agentmemory/mcp") || cmd.includes("agentmemory mcp");
|
|
416
|
+
if (
|
|
417
|
+
!isMcpShim &&
|
|
418
|
+
(cmd.includes("@agentmemory/agentmemory") ||
|
|
419
|
+
cmd.includes("iii-config.yaml") ||
|
|
420
|
+
cmd.includes("iii") ||
|
|
421
|
+
(cmd.includes("agentmemory") && !cmd.includes("mcp")))
|
|
422
|
+
) {
|
|
423
|
+
if (!discovered.agentmemory) discovered.agentmemory = { pid, command: cmd, url: "http://localhost:3113" };
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
if (cmd.includes("headroom proxy") || (cmd.includes("headroom") && !cmd.includes("aih "))) {
|
|
427
|
+
if (!discovered.headroom) discovered.headroom = { pid, command: cmd, url: "http://localhost:8787/dashboard" };
|
|
398
428
|
}
|
|
399
|
-
|
|
400
|
-
|
|
429
|
+
}
|
|
430
|
+
} catch {}
|
|
401
431
|
}
|
|
402
432
|
|
|
403
433
|
return discovered;
|
|
404
434
|
}
|
|
405
|
-
|