@mnemom/mnemom 0.17.0-next.6 → 0.17.0-next.7
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/commands/agent-config.d.ts +17 -0
- package/dist/commands/agent-config.js +173 -0
- package/dist/commands/{code-doctor.d.ts → agent-doctor.d.ts} +2 -2
- package/dist/commands/{code-doctor.js → agent-doctor.js} +27 -22
- package/dist/commands/{code-invite.d.ts → agent-invite.d.ts} +18 -18
- package/dist/commands/{code-invite.js → agent-invite.js} +30 -30
- package/dist/commands/{code-session.d.ts → agent-session.d.ts} +2 -2
- package/dist/commands/{code-session.js → agent-session.js} +8 -8
- package/dist/commands/{code-setup.d.ts → agent-setup.d.ts} +13 -13
- package/dist/commands/{code-setup.js → agent-setup.js} +46 -42
- package/dist/commands/{code.d.ts → agent.d.ts} +14 -14
- package/dist/commands/{code.js → agent.js} +76 -76
- package/dist/commands/agents.d.ts +2 -2
- package/dist/commands/agents.js +5 -5
- package/dist/commands/onboard.js +1 -1
- package/dist/commands/wrap.js +1 -1
- package/dist/index.js +42 -47
- package/dist/lib/{code.d.ts → agent.d.ts} +9 -9
- package/dist/lib/{code.js → agent.js} +14 -14
- package/dist/lib/api.d.ts +4 -4
- package/dist/lib/api.js +9 -9
- package/dist/lib/{code-config.d.ts → launcher-config.d.ts} +23 -23
- package/dist/lib/{code-config.js → launcher-config.js} +31 -31
- package/dist/lib/version-gate.js +1 -1
- package/dist/rc-proxy.mjs +297 -134
- package/package.json +1 -1
- package/dist/commands/code-config.d.ts +0 -17
- package/dist/commands/code-config.js +0 -147
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* lib/code-config.ts — persistent per-customer settings for `mnemom
|
|
2
|
+
* lib/code-config.ts — persistent per-customer settings for `mnemom agent`.
|
|
3
3
|
*
|
|
4
|
-
* Settings live in a human-editable TOML file at ~/.mnemom/
|
|
4
|
+
* Settings live in a human-editable TOML file at ~/.mnemom/launcher.toml (the
|
|
5
5
|
* Cargo/Codex `config.toml` convention — comments allowed, easy to hand-edit) so
|
|
6
6
|
* a customer never has to retype their flags. The SECRET Anthropic key is
|
|
7
|
-
* deliberately NOT stored here: it stays in ~/.mnemom/
|
|
7
|
+
* deliberately NOT stored here: it stays in ~/.mnemom/launcher.json at 0600 (see
|
|
8
8
|
* commands/code.ts), so the file customers open, edit, and share never carries a
|
|
9
9
|
* credential — the same split gh (config.yml/hosts.yml), aws (config/credentials)
|
|
10
10
|
* and Codex (config.toml/auth.json) use.
|
|
11
11
|
*
|
|
12
|
-
* Precedence, highest wins: command-line FLAG > ENV >
|
|
13
|
-
* `
|
|
12
|
+
* Precedence, highest wins: command-line FLAG > ENV > launcher.toml > built-in.
|
|
13
|
+
* `loadLauncherConfig` is pure parse+validate; `applyConfigToEnv` folds the
|
|
14
14
|
* env-backed settings UNDER any real env var (so env still wins and the
|
|
15
15
|
* resolvers in lib/code.ts keep the built-in default as the final fallback);
|
|
16
16
|
* the caller folds the plain-value settings under the CLI flags.
|
|
@@ -19,9 +19,9 @@ import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "
|
|
|
19
19
|
import { dirname, join } from "node:path";
|
|
20
20
|
import { parse as parseToml, stringify as stringifyToml, TomlError } from "smol-toml";
|
|
21
21
|
import { MNEMOM_DIR } from "./config.js";
|
|
22
|
-
import { isPositiveInt, isPositiveNumber } from "./
|
|
23
|
-
/** The human-editable settings file. Secret key lives elsewhere (
|
|
24
|
-
export const
|
|
22
|
+
import { isPositiveInt, isPositiveNumber } from "./agent.js";
|
|
23
|
+
/** The human-editable settings file. Secret key lives elsewhere (launcher.json). */
|
|
24
|
+
export const LAUNCHER_CONFIG_PATH = join(MNEMOM_DIR, "launcher.toml");
|
|
25
25
|
const LAUNCH_SHAPES = ["terminal", "remote-control", "server"];
|
|
26
26
|
const EFFORTS = ["low", "medium", "high", "xhigh", "max"];
|
|
27
27
|
const KEY_SOURCES = ["env", "store", "prompt"];
|
|
@@ -147,18 +147,18 @@ export function configKeySpec(key) {
|
|
|
147
147
|
return CONFIG_KEYS.find((k) => k.key === key);
|
|
148
148
|
}
|
|
149
149
|
/**
|
|
150
|
-
* Parse + validate a TOML settings document into a
|
|
150
|
+
* Parse + validate a TOML settings document into a LauncherConfig. Pure (no fs), so
|
|
151
151
|
* it is unit-testable. Unknown top-level keys are ignored (forward-compatible);
|
|
152
152
|
* known keys with the wrong shape throw a human-readable error.
|
|
153
153
|
*/
|
|
154
|
-
export function
|
|
154
|
+
export function parseLauncherConfig(text) {
|
|
155
155
|
let raw;
|
|
156
156
|
try {
|
|
157
157
|
raw = parseToml(text);
|
|
158
158
|
}
|
|
159
159
|
catch (err) {
|
|
160
160
|
const detail = err instanceof TomlError ? err.message : String(err);
|
|
161
|
-
throw new Error(`could not parse
|
|
161
|
+
throw new Error(`could not parse launcher.toml: ${detail}`, { cause: err });
|
|
162
162
|
}
|
|
163
163
|
const cfg = {};
|
|
164
164
|
const str = (v) => typeof v === "string" && v.trim() ? v.trim() : v === undefined ? undefined : String(v);
|
|
@@ -192,12 +192,12 @@ export function parseCodeConfig(text) {
|
|
|
192
192
|
return cfg;
|
|
193
193
|
}
|
|
194
194
|
/**
|
|
195
|
-
* Load the settings from ~/.mnemom/
|
|
195
|
+
* Load the settings from ~/.mnemom/launcher.toml (or `path`). A missing file is an
|
|
196
196
|
* empty config (never an error — first run has none). A malformed or invalid
|
|
197
197
|
* file throws with the path so the customer can fix it, rather than silently
|
|
198
198
|
* launching with the wrong settings.
|
|
199
199
|
*/
|
|
200
|
-
export function
|
|
200
|
+
export function loadLauncherConfig(path = LAUNCHER_CONFIG_PATH) {
|
|
201
201
|
if (!existsSync(path))
|
|
202
202
|
return {};
|
|
203
203
|
let text;
|
|
@@ -208,15 +208,15 @@ export function loadCodeConfig(path = CODE_CONFIG_PATH) {
|
|
|
208
208
|
return {};
|
|
209
209
|
}
|
|
210
210
|
try {
|
|
211
|
-
return
|
|
211
|
+
return parseLauncherConfig(text);
|
|
212
212
|
}
|
|
213
213
|
catch (err) {
|
|
214
214
|
const msg = err instanceof Error ? err.message : String(err);
|
|
215
|
-
throw new Error(`mnemom
|
|
215
|
+
throw new Error(`mnemom agent: ${msg}\n Fix or remove ${path}.`, { cause: err });
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
|
-
/** Serialize a
|
|
219
|
-
export function
|
|
218
|
+
/** Serialize a LauncherConfig back to TOML (snake_case keys), with a header comment. */
|
|
219
|
+
export function serializeLauncherConfig(cfg) {
|
|
220
220
|
const doc = {};
|
|
221
221
|
if (cfg.gateway !== undefined)
|
|
222
222
|
doc.gateway = cfg.gateway;
|
|
@@ -243,39 +243,39 @@ export function serializeCodeConfig(cfg) {
|
|
|
243
243
|
gr.stall_turns = g.stallTurns;
|
|
244
244
|
doc.guardrails = gr;
|
|
245
245
|
}
|
|
246
|
-
const header = "# ~/.mnemom/
|
|
246
|
+
const header = "# ~/.mnemom/launcher.toml — settings for `mnemom agent` (the governed coding-agent launcher).\n" +
|
|
247
247
|
"# Command-line flags override these; these override the built-in defaults.\n" +
|
|
248
|
-
"# The secret Anthropic key is NOT here — it lives in ~/.mnemom/
|
|
249
|
-
"# Edit with `mnemom
|
|
248
|
+
"# The secret Anthropic key is NOT here — it lives in ~/.mnemom/launcher.json (0600).\n" +
|
|
249
|
+
"# Edit with `mnemom agent config edit`, or set one key with `mnemom agent config set <key> <value>`.\n\n";
|
|
250
250
|
const body = Object.keys(doc).length ? stringifyToml(doc) : "";
|
|
251
251
|
return `${header}${body}${body.endsWith("\n") || !body ? "" : "\n"}`;
|
|
252
252
|
}
|
|
253
|
-
/** Persist a
|
|
254
|
-
export function
|
|
253
|
+
/** Persist a LauncherConfig to `path` (default launcher.toml), atomically (temp+rename), 0600. */
|
|
254
|
+
export function writeLauncherConfig(cfg, path = LAUNCHER_CONFIG_PATH) {
|
|
255
255
|
const dir = dirname(path);
|
|
256
256
|
mkdirSync(dir, { recursive: true });
|
|
257
257
|
const tmp = join(dir, `.code-toml-tmp-${process.pid}-${Date.now()}`);
|
|
258
|
-
writeFileSync(tmp,
|
|
258
|
+
writeFileSync(tmp, serializeLauncherConfig(cfg), { mode: 0o600 });
|
|
259
259
|
renameSync(tmp, path);
|
|
260
260
|
}
|
|
261
261
|
/**
|
|
262
262
|
* Fold the ENV-backed settings from config UNDER the environment: set the
|
|
263
|
-
*
|
|
263
|
+
* MNEMOM_AGENT_* var ONLY when it is not already present, so a real env var (and
|
|
264
264
|
* therefore a flag that set one) still wins. The resolvers in lib/code.ts then
|
|
265
265
|
* apply the built-in default when neither env nor config supplied a value.
|
|
266
266
|
*
|
|
267
|
-
* launch maps to
|
|
267
|
+
* launch maps to MNEMOM_AGENT_REMOTE_CONTROL using that var's existing contract
|
|
268
268
|
* (see resolveLaunchShape): terminal→"0", remote-control→"1", server→"server".
|
|
269
269
|
*/
|
|
270
270
|
export function applyConfigToEnv(cfg, env = process.env) {
|
|
271
|
-
if (cfg.gateway && !(env.
|
|
272
|
-
env.
|
|
271
|
+
if (cfg.gateway && !(env.MNEMOM_AGENT_GATEWAY ?? "").trim()) {
|
|
272
|
+
env.MNEMOM_AGENT_GATEWAY = cfg.gateway;
|
|
273
273
|
}
|
|
274
|
-
if (cfg.cli && !(env.
|
|
275
|
-
env.
|
|
274
|
+
if (cfg.cli && !(env.MNEMOM_AGENT_CLI ?? "").trim()) {
|
|
275
|
+
env.MNEMOM_AGENT_CLI = cfg.cli;
|
|
276
276
|
}
|
|
277
|
-
if (cfg.launch && !(env.
|
|
278
|
-
env.
|
|
277
|
+
if (cfg.launch && !(env.MNEMOM_AGENT_REMOTE_CONTROL ?? "").trim()) {
|
|
278
|
+
env.MNEMOM_AGENT_REMOTE_CONTROL =
|
|
279
279
|
cfg.launch === "server" ? "server" : cfg.launch === "remote-control" ? "1" : "0";
|
|
280
280
|
}
|
|
281
281
|
}
|
package/dist/lib/version-gate.js
CHANGED
|
@@ -67,7 +67,7 @@ export function enforceMinCliVersion(response, exit = process.exit, write = (chu
|
|
|
67
67
|
return;
|
|
68
68
|
exited = true;
|
|
69
69
|
write(`\n✖ Your Mnemom CLI (v${CLI_VERSION}) is too old for this server (minimum v${floor}).\n` +
|
|
70
|
-
` Old CLIs can silently drop newer request fields — e.g. \`--org\` on \`mnemom
|
|
70
|
+
` Old CLIs can silently drop newer request fields — e.g. \`--org\` on \`mnemom agent claim\`.\n\n` +
|
|
71
71
|
` Upgrade: npm i -g @mnemom/mnemom@latest\n\n`);
|
|
72
72
|
exit(1);
|
|
73
73
|
}
|