@sns-myagent/cli 0.3.7 → 0.3.8
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/package.json +3 -3
- package/src/cli/index.ts +66 -2
- package/src/config/defaults.ts +5 -3
- package/src/config/schema.ts +8 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@sns-myagent/cli",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.8",
|
|
5
5
|
"description": "SNS-MyAgent \u2014 BYOK coding agent CLI. Multi-agent + Telegram + self-learning memory. ~120MB binary, zero forced cost.",
|
|
6
6
|
"homepage": "https://github.com/Reihantt6/sns-myagent",
|
|
7
7
|
"author": "Reihantt6",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"scripts": {
|
|
36
36
|
"fetch-binary": "node scripts/fetch-binary.mjs",
|
|
37
37
|
"postinstall": "node scripts/fetch-binary.mjs && node scripts/apply-pi-natives-patch.js",
|
|
38
|
-
"build": "bun build --compile --define process.env.PI_COMPILED='\"true\"' --define process.env.PKG_VERSION='\"0.3.
|
|
38
|
+
"build": "bun build --compile --define process.env.PI_COMPILED='\"true\"' --define process.env.PKG_VERSION='\"0.3.8\"' --no-compile-autoload-bunfig --no-compile-autoload-dotenv --no-compile-autoload-tsconfig --no-compile-autoload-package-json --keep-names --outfile bin/snsagent-linux-x64 ./src/cli/entry.ts && cp bin/snsagent-linux-x64 bin/snsagent",
|
|
39
39
|
"check": "biome check . && bun run check:types",
|
|
40
40
|
"check:types": "tsgo -p tsconfig.json --noEmit",
|
|
41
41
|
"lint": "biome lint .",
|
|
@@ -117,4 +117,4 @@
|
|
|
117
117
|
"CHANGELOG.md",
|
|
118
118
|
"dist/types"
|
|
119
119
|
]
|
|
120
|
-
}
|
|
120
|
+
}
|
package/src/cli/index.ts
CHANGED
|
@@ -16,6 +16,9 @@ import type { Config } from "../config/schema.js";
|
|
|
16
16
|
import { defaultConfigFn } from "../config/loader.js";
|
|
17
17
|
import { startTelegramAdapter, stopTelegramAdapter } from "../adapters/telegram/index.js";
|
|
18
18
|
import { createForwardToAgent, resetChatSession, getBridgeStats } from "../adapters/telegram/bridge.js";
|
|
19
|
+
import { createInterface } from "node:readline/promises";
|
|
20
|
+
import { stdin, stdout } from "node:process";
|
|
21
|
+
import chalk from "chalk";
|
|
19
22
|
|
|
20
23
|
// ---------- package version (single source of truth) ----------
|
|
21
24
|
|
|
@@ -61,7 +64,7 @@ function cmdVersion(): number {
|
|
|
61
64
|
return 0;
|
|
62
65
|
}
|
|
63
66
|
|
|
64
|
-
function cmdInit(): number {
|
|
67
|
+
async function cmdInit(): Promise<number> {
|
|
65
68
|
const path = configPath();
|
|
66
69
|
try {
|
|
67
70
|
const existing = loadConfig();
|
|
@@ -69,9 +72,70 @@ function cmdInit(): number {
|
|
|
69
72
|
process.stdout.write(`✓ config already exists at ${path}\n`);
|
|
70
73
|
return 0;
|
|
71
74
|
}
|
|
75
|
+
|
|
76
|
+
// Interactive memory backend selection
|
|
77
|
+
const rl = createInterface({ input: stdin, output: stdout });
|
|
78
|
+
|
|
79
|
+
process.stdout.write("\n");
|
|
80
|
+
process.stdout.write(` ${chalk.cyan("●")} ${chalk.bold("Memory Backend Selection")}\n`);
|
|
81
|
+
process.stdout.write(` ${chalk.dim("Select memory backend (default: mnemopi):")}\n`);
|
|
82
|
+
process.stdout.write(` ${chalk.cyan("1")} mnemopi (default) — SQLite + vector + graph, offline, no config\n`);
|
|
83
|
+
process.stdout.write(` ${chalk.cyan("2")} local — rollout summary only\n`);
|
|
84
|
+
process.stdout.write(` ${chalk.cyan("3")} mnemosyne — advanced local (Python daemon)\n`);
|
|
85
|
+
process.stdout.write(` ${chalk.cyan("4")} mem0 — cloud API (needs MEM0_API_KEY)\n`);
|
|
86
|
+
process.stdout.write(` ${chalk.cyan("5")} lcm — local server (needs LCM_HOST)\n`);
|
|
87
|
+
process.stdout.write(` ${chalk.cyan("6")} hindsight — cloud (needs HINDSIGHT_API_KEY)\n`);
|
|
88
|
+
process.stdout.write(` ${chalk.cyan("7")} off — disabled\n`);
|
|
89
|
+
process.stdout.write(` [1] `);
|
|
90
|
+
|
|
91
|
+
const answer = await rl.question("");
|
|
92
|
+
|
|
93
|
+
let backend: "mnemopi" | "hindsight" | "mnemosyne" | "mem0" | "lcm" | "local" | "off" = "mnemopi";
|
|
94
|
+
switch (answer.trim()) {
|
|
95
|
+
case "1":
|
|
96
|
+
case "":
|
|
97
|
+
backend = "mnemopi";
|
|
98
|
+
break;
|
|
99
|
+
case "2":
|
|
100
|
+
backend = "local";
|
|
101
|
+
break;
|
|
102
|
+
case "3":
|
|
103
|
+
backend = "mnemosyne";
|
|
104
|
+
break;
|
|
105
|
+
case "4":
|
|
106
|
+
backend = "mem0";
|
|
107
|
+
break;
|
|
108
|
+
case "5":
|
|
109
|
+
backend = "lcm";
|
|
110
|
+
break;
|
|
111
|
+
case "6":
|
|
112
|
+
backend = "hindsight";
|
|
113
|
+
break;
|
|
114
|
+
case "7":
|
|
115
|
+
backend = "off";
|
|
116
|
+
break;
|
|
117
|
+
default:
|
|
118
|
+
process.stdout.write(` ${chalk.dim("unknown option, using default (mnemopi)")}\n`);
|
|
119
|
+
backend = "mnemopi";
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Mnemosyne needs Python daemon
|
|
123
|
+
if (backend === "mnemosyne") {
|
|
124
|
+
process.stdout.write(`\n ${chalk.cyan("●")} mnemosyne requires Python daemon.\n`);
|
|
125
|
+
process.stdout.write(` ${chalk.dim("Install now? (pip install mnemosyne) [Y/n] ")}`);
|
|
126
|
+
const yn = await rl.question("");
|
|
127
|
+
if (!yn || yn.toLowerCase() === "y") {
|
|
128
|
+
process.stdout.write(` ${chalk.dim("installing mnemosyne... (placeholder)")}\n`);
|
|
129
|
+
// TODO: actual pip install
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
rl.close();
|
|
134
|
+
|
|
72
135
|
const cfg = defaultConfigFn();
|
|
136
|
+
cfg.memory = { ...cfg.memory, backend };
|
|
73
137
|
saveConfig(cfg);
|
|
74
|
-
process.stdout.write(`✓ created ${path}\n`);
|
|
138
|
+
process.stdout.write(`✓ created ${path} (memory backend: ${backend})\n`);
|
|
75
139
|
return 0;
|
|
76
140
|
} catch (err) {
|
|
77
141
|
process.stderr.write(`✗ init failed: ${(err as Error).message}\n`);
|
package/src/config/defaults.ts
CHANGED
|
@@ -26,6 +26,7 @@ export const defaultConfig: Config = {
|
|
|
26
26
|
path: "memory.jsonl",
|
|
27
27
|
maxEntries: 1000,
|
|
28
28
|
autoSummarize: true,
|
|
29
|
+
backend: "mnemopi",
|
|
29
30
|
},
|
|
30
31
|
};
|
|
31
32
|
|
|
@@ -44,9 +45,10 @@ export const DEFAULT_CONFIG_YAML =
|
|
|
44
45
|
` allowedChatIds: []\n` +
|
|
45
46
|
` pollIntervalMs: ${defaultConfig.telegram.pollIntervalMs}\n` +
|
|
46
47
|
`memory:\n` +
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
` path: ${defaultConfig.memory.path}\n` +
|
|
49
|
+
` maxEntries: ${defaultConfig.memory.maxEntries}\n` +
|
|
50
|
+
` autoSummarize: ${defaultConfig.memory.autoSummarize}\n` +
|
|
51
|
+
` backend: ${defaultConfig.memory.backend}\n`;
|
|
50
52
|
|
|
51
53
|
/** Default LLM provider id. */
|
|
52
54
|
export const DEFAULT_PROVIDER = defaultConfig.model.provider;
|
package/src/config/schema.ts
CHANGED
|
@@ -32,6 +32,8 @@ export interface MemoryConfig {
|
|
|
32
32
|
maxEntries: number;
|
|
33
33
|
/** Auto-summarize old entries when count exceeds threshold. */
|
|
34
34
|
autoSummarize: boolean;
|
|
35
|
+
/** Memory backend to use. */
|
|
36
|
+
backend: "mnemopi" | "hindsight" | "mnemosyne" | "mem0" | "lcm" | "local" | "off";
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
export interface Config {
|
|
@@ -109,6 +111,11 @@ export function validateConfig(raw: unknown): Config {
|
|
|
109
111
|
if (typeof mem.autoSummarize !== "boolean") {
|
|
110
112
|
throw new Error("config.memory.autoSummarize must be boolean");
|
|
111
113
|
}
|
|
114
|
+
// Optional backend field with default
|
|
115
|
+
const backend = mem.backend;
|
|
116
|
+
if (backend !== undefined && !isNonEmptyString(backend)) {
|
|
117
|
+
throw new Error("config.memory.backend must be a string if present");
|
|
118
|
+
}
|
|
112
119
|
|
|
113
120
|
const extra = r.extra;
|
|
114
121
|
if (extra !== undefined && (typeof extra !== "object" || extra === null || Array.isArray(extra))) {
|
|
@@ -133,6 +140,7 @@ export function validateConfig(raw: unknown): Config {
|
|
|
133
140
|
path: mem.path as string,
|
|
134
141
|
maxEntries: mem.maxEntries as number,
|
|
135
142
|
autoSummarize: mem.autoSummarize as boolean,
|
|
143
|
+
backend: (mem.backend ?? "mnemopi") as "mnemopi" | "hindsight" | "mnemosyne" | "mem0" | "lcm" | "local" | "off",
|
|
136
144
|
},
|
|
137
145
|
extra: extra as Record<string, unknown> | undefined,
|
|
138
146
|
};
|