@mnemom/mnemom 0.16.1 → 0.17.0-next.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/README.md +1 -0
- package/dist/commands/agents.d.ts +14 -0
- package/dist/commands/agents.js +100 -2
- package/dist/commands/card.d.ts +43 -0
- package/dist/commands/card.js +153 -102
- package/dist/commands/code-config.d.ts +17 -0
- package/dist/commands/code-config.js +147 -0
- package/dist/commands/code-doctor.d.ts +18 -0
- package/dist/commands/code-doctor.js +138 -0
- package/dist/commands/code-setup.d.ts +97 -0
- package/dist/commands/code-setup.js +330 -0
- package/dist/commands/code.d.ts +133 -0
- package/dist/commands/code.js +661 -0
- package/dist/commands/logs.js +11 -1
- package/dist/commands/onboard.d.ts +59 -0
- package/dist/commands/onboard.js +395 -0
- package/dist/commands/org.d.ts +13 -0
- package/dist/commands/org.js +63 -2
- package/dist/commands/protection.d.ts +10 -0
- package/dist/commands/protection.js +109 -0
- package/dist/commands/status.js +5 -0
- package/dist/commands/try-me.js +16 -1
- package/dist/commands/usage.d.ts +35 -0
- package/dist/commands/usage.js +265 -0
- package/dist/commands/wrap.d.ts +28 -0
- package/dist/commands/wrap.js +331 -0
- package/dist/index.js +315 -7
- package/dist/lib/agent-config.d.ts +27 -0
- package/dist/lib/agent-config.js +86 -0
- package/dist/lib/api.d.ts +139 -1
- package/dist/lib/api.js +132 -183
- package/dist/lib/cli-config.d.ts +33 -0
- package/dist/lib/cli-config.js +70 -0
- package/dist/lib/code-config.d.ts +78 -0
- package/dist/lib/code-config.js +281 -0
- package/dist/lib/code.d.ts +154 -0
- package/dist/lib/code.js +252 -0
- package/dist/lib/config.d.ts +12 -0
- package/dist/lib/config.js +55 -3
- package/dist/lib/keyed-identity.d.ts +35 -0
- package/dist/lib/keyed-identity.js +363 -0
- package/dist/lib/protection-drift.d.ts +117 -0
- package/dist/lib/protection-drift.js +180 -0
- package/dist/lib/skills.js +25 -12
- package/dist/lib/version-gate.d.ts +37 -0
- package/dist/lib/version-gate.js +84 -0
- package/dist/rc-proxy.mjs +341 -0
- package/package.json +9 -7
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `mnemom code config …` — read and write the persistent per-customer settings
|
|
3
|
+
* for `mnemom code` (see lib/code-config.ts). A sub-verb of `mnemom code`, so a
|
|
4
|
+
* customer configures the launcher once and never retypes their flags:
|
|
5
|
+
*
|
|
6
|
+
* mnemom code config list # show the current settings
|
|
7
|
+
* mnemom code config get <key> # print one value
|
|
8
|
+
* mnemom code config set <key> <value> # validate + persist one value
|
|
9
|
+
* mnemom code config unset <key> # remove one value
|
|
10
|
+
* mnemom code config edit # open ~/.mnemom/code.toml in $EDITOR
|
|
11
|
+
* mnemom code config path # print the settings file path
|
|
12
|
+
*
|
|
13
|
+
* Settable keys are the single source of truth in lib/code-config.ts CONFIG_KEYS.
|
|
14
|
+
* The secret Anthropic key is NOT a config key — it lives in ~/.mnemom/code.json.
|
|
15
|
+
*/
|
|
16
|
+
import { spawnSync } from "node:child_process";
|
|
17
|
+
import { existsSync } from "node:fs";
|
|
18
|
+
import { CODE_CONFIG_PATH, CONFIG_KEYS, configKeySpec, loadCodeConfig, writeCodeConfig, } from "../lib/code-config.js";
|
|
19
|
+
const out = (line = "") => console.log(line);
|
|
20
|
+
const err = (line = "") => console.error(line);
|
|
21
|
+
/** Entry point for `mnemom code config <verb> [args...]`. Throws on misuse. */
|
|
22
|
+
export async function codeConfigCommand(argv) {
|
|
23
|
+
const [verb, ...rest] = argv;
|
|
24
|
+
switch (verb) {
|
|
25
|
+
case undefined:
|
|
26
|
+
case "list":
|
|
27
|
+
return listConfig();
|
|
28
|
+
case "path":
|
|
29
|
+
out(CODE_CONFIG_PATH);
|
|
30
|
+
return;
|
|
31
|
+
case "get":
|
|
32
|
+
return getConfig(rest[0]);
|
|
33
|
+
case "set":
|
|
34
|
+
return setConfig(rest[0], rest[1]);
|
|
35
|
+
case "unset":
|
|
36
|
+
return unsetConfig(rest[0]);
|
|
37
|
+
case "edit":
|
|
38
|
+
return editConfig();
|
|
39
|
+
default:
|
|
40
|
+
throw new Error(`mnemom code config: unknown verb '${verb}'. Use list | get | set | unset | edit | path.`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function listConfig() {
|
|
44
|
+
const cfg = loadCodeConfig();
|
|
45
|
+
const rows = [];
|
|
46
|
+
for (const spec of CONFIG_KEYS) {
|
|
47
|
+
const v = spec.get(cfg);
|
|
48
|
+
if (v !== undefined)
|
|
49
|
+
rows.push([spec.key, String(v)]);
|
|
50
|
+
}
|
|
51
|
+
if (!rows.length) {
|
|
52
|
+
out(`No settings yet at ${CODE_CONFIG_PATH}.`);
|
|
53
|
+
out("Set one with: mnemom code config set <key> <value>");
|
|
54
|
+
out("");
|
|
55
|
+
out("Settable keys:");
|
|
56
|
+
for (const spec of CONFIG_KEYS)
|
|
57
|
+
out(` ${spec.key.padEnd(22)} ${spec.describe}`);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const width = Math.max(...rows.map(([k]) => k.length));
|
|
61
|
+
out(`# ${CODE_CONFIG_PATH}`);
|
|
62
|
+
for (const [k, v] of rows)
|
|
63
|
+
out(`${k.padEnd(width)} ${v}`);
|
|
64
|
+
}
|
|
65
|
+
function getConfig(key) {
|
|
66
|
+
if (!key)
|
|
67
|
+
throw new Error("mnemom code config get: a <key> is required.");
|
|
68
|
+
const spec = requireSpec(key);
|
|
69
|
+
const value = spec.get(loadCodeConfig());
|
|
70
|
+
if (value === undefined) {
|
|
71
|
+
err(`mnemom code config: '${key}' is not set.`);
|
|
72
|
+
process.exitCode = 1;
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
out(String(value));
|
|
76
|
+
}
|
|
77
|
+
function setConfig(key, value) {
|
|
78
|
+
if (!key)
|
|
79
|
+
throw new Error("mnemom code config set: a <key> is required.");
|
|
80
|
+
if (value === undefined)
|
|
81
|
+
throw new Error(`mnemom code config set: a value for '${key}' is required.`);
|
|
82
|
+
const spec = requireSpec(key);
|
|
83
|
+
const cfg = loadCodeConfig();
|
|
84
|
+
spec.set(cfg, value); // validates + coerces; throws on invalid
|
|
85
|
+
writeCodeConfig(cfg);
|
|
86
|
+
out(`${key} = ${String(spec.get(cfg))} (saved to ${CODE_CONFIG_PATH})`);
|
|
87
|
+
}
|
|
88
|
+
function unsetConfig(key) {
|
|
89
|
+
if (!key)
|
|
90
|
+
throw new Error("mnemom code config unset: a <key> is required.");
|
|
91
|
+
requireSpec(key);
|
|
92
|
+
const cfg = loadCodeConfig();
|
|
93
|
+
deleteKey(cfg, key);
|
|
94
|
+
writeCodeConfig(cfg);
|
|
95
|
+
out(`unset ${key} (saved to ${CODE_CONFIG_PATH})`);
|
|
96
|
+
}
|
|
97
|
+
function editConfig() {
|
|
98
|
+
// Seed a header-only file so $EDITOR opens something with guidance, not a blank.
|
|
99
|
+
if (!existsSync(CODE_CONFIG_PATH))
|
|
100
|
+
writeCodeConfig(loadCodeConfig());
|
|
101
|
+
const editor = process.env.VISUAL || process.env.EDITOR || fallbackEditor();
|
|
102
|
+
const res = spawnSync(editor, [CODE_CONFIG_PATH], { stdio: "inherit" });
|
|
103
|
+
if (res.error) {
|
|
104
|
+
throw new Error(`mnemom code config edit: could not launch editor '${editor}': ${res.error.message}\n` +
|
|
105
|
+
` Set $EDITOR, or edit ${CODE_CONFIG_PATH} directly.`);
|
|
106
|
+
}
|
|
107
|
+
// Re-parse so a typo surfaces now, not at the next launch.
|
|
108
|
+
loadCodeConfig();
|
|
109
|
+
out(`Saved ${CODE_CONFIG_PATH}.`);
|
|
110
|
+
}
|
|
111
|
+
function fallbackEditor() {
|
|
112
|
+
for (const cand of ["nano", "vim", "vi"]) {
|
|
113
|
+
const r = spawnSync("sh", ["-c", `command -v "$1" >/dev/null 2>&1`, "sh", cand], {
|
|
114
|
+
stdio: "ignore",
|
|
115
|
+
});
|
|
116
|
+
if (r.status === 0)
|
|
117
|
+
return cand;
|
|
118
|
+
}
|
|
119
|
+
return "vi";
|
|
120
|
+
}
|
|
121
|
+
function requireSpec(key) {
|
|
122
|
+
const spec = configKeySpec(key);
|
|
123
|
+
if (!spec) {
|
|
124
|
+
throw new Error(`mnemom code config: unknown key '${key}'.\n Known keys: ${CONFIG_KEYS.map((k) => k.key).join(", ")}`);
|
|
125
|
+
}
|
|
126
|
+
return spec;
|
|
127
|
+
}
|
|
128
|
+
/** Remove a (possibly dotted) key from a config object, pruning an emptied table. */
|
|
129
|
+
function deleteKey(cfg, key) {
|
|
130
|
+
if (key.startsWith("guardrails.")) {
|
|
131
|
+
const g = cfg.guardrails;
|
|
132
|
+
if (!g)
|
|
133
|
+
return;
|
|
134
|
+
const field = key.slice("guardrails.".length);
|
|
135
|
+
if (field === "max_turns")
|
|
136
|
+
delete g.maxTurns;
|
|
137
|
+
if (field === "budget_usd")
|
|
138
|
+
delete g.budgetUsd;
|
|
139
|
+
if (field === "stall_turns")
|
|
140
|
+
delete g.stallTurns;
|
|
141
|
+
if (g.maxTurns === undefined && g.budgetUsd === undefined && g.stallTurns === undefined) {
|
|
142
|
+
delete cfg.guardrails;
|
|
143
|
+
}
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
delete cfg[key === "key_source" ? "keySource" : key];
|
|
147
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `mnemom code doctor` — a read-only preflight for `mnemom code`. It checks the
|
|
3
|
+
* things a governed launch needs and prints a checklist with clear, actionable
|
|
4
|
+
* remediation, so a customer can see at a glance why a launch would fail before
|
|
5
|
+
* it does. Writes nothing and reads no secret VALUE (only whether a key is
|
|
6
|
+
* resolvable). Exits non-zero when the machine is not launch-ready (no coding
|
|
7
|
+
* agent CLI, or no Anthropic key), so it can gate a script.
|
|
8
|
+
*
|
|
9
|
+
* Checks: settings file, coding-agent CLI, Anthropic key source, gateway health
|
|
10
|
+
* (200 + the x-mnemom-verdict header that proves the governance pipeline is
|
|
11
|
+
* live), Remote-Control capability (node + openssl + the --remote-control flag),
|
|
12
|
+
* and claude.ai login (informational — Remote Control needs it).
|
|
13
|
+
*/
|
|
14
|
+
export interface DoctorOptions {
|
|
15
|
+
cli?: string;
|
|
16
|
+
}
|
|
17
|
+
/** Run the preflight and print the checklist. Sets process.exitCode on failure. */
|
|
18
|
+
export declare function codeDoctorCommand(options?: DoctorOptions): Promise<void>;
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `mnemom code doctor` — a read-only preflight for `mnemom code`. It checks the
|
|
3
|
+
* things a governed launch needs and prints a checklist with clear, actionable
|
|
4
|
+
* remediation, so a customer can see at a glance why a launch would fail before
|
|
5
|
+
* it does. Writes nothing and reads no secret VALUE (only whether a key is
|
|
6
|
+
* resolvable). Exits non-zero when the machine is not launch-ready (no coding
|
|
7
|
+
* agent CLI, or no Anthropic key), so it can gate a script.
|
|
8
|
+
*
|
|
9
|
+
* Checks: settings file, coding-agent CLI, Anthropic key source, gateway health
|
|
10
|
+
* (200 + the x-mnemom-verdict header that proves the governance pipeline is
|
|
11
|
+
* live), Remote-Control capability (node + openssl + the --remote-control flag),
|
|
12
|
+
* and claude.ai login (informational — Remote Control needs it).
|
|
13
|
+
*/
|
|
14
|
+
import { spawnSync } from "node:child_process";
|
|
15
|
+
import { existsSync } from "node:fs";
|
|
16
|
+
import { anthropicKeySource, checkRcCapability, resolveCliBin, } from "./code.js";
|
|
17
|
+
import { isProdGateway, resolveAnthropicDoor, resolveGatewayHost, } from "../lib/code.js";
|
|
18
|
+
import { CODE_CONFIG_PATH } from "../lib/code-config.js";
|
|
19
|
+
const MARK = { ok: "[ ok ]", warn: "[warn]", miss: "[MISS]", info: "[info]" };
|
|
20
|
+
const out = (line = "") => console.log(line);
|
|
21
|
+
/** Run the preflight and print the checklist. Sets process.exitCode on failure. */
|
|
22
|
+
export async function codeDoctorCommand(options = {}) {
|
|
23
|
+
const env = process.env;
|
|
24
|
+
const lines = [];
|
|
25
|
+
const add = (mark, text, hint) => {
|
|
26
|
+
lines.push({ mark, text, hint });
|
|
27
|
+
};
|
|
28
|
+
// ── settings file ──
|
|
29
|
+
if (existsSync(CODE_CONFIG_PATH))
|
|
30
|
+
add("ok", `settings: ${CODE_CONFIG_PATH}`);
|
|
31
|
+
else
|
|
32
|
+
add("info", `settings: none yet (${CODE_CONFIG_PATH}) — using built-in defaults`, "save your defaults with `mnemom code config set <key> <value>`");
|
|
33
|
+
// ── coding-agent CLI ──
|
|
34
|
+
let cli;
|
|
35
|
+
try {
|
|
36
|
+
cli = resolveCliBin(options.cli, env);
|
|
37
|
+
add("ok", `coding-agent CLI: ${cli.name} (${cli.bin})`);
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
add("miss", `coding-agent CLI: ${err instanceof Error ? err.message.split("\n")[0] : err}`, "install Claude Code, or pass --cli <name|/full/path> / set it with `mnemom code config set cli <path>`");
|
|
41
|
+
}
|
|
42
|
+
// ── Anthropic key ──
|
|
43
|
+
const keySrc = anthropicKeySource(env);
|
|
44
|
+
if (keySrc === "env")
|
|
45
|
+
add("ok", "Anthropic key: found in the environment");
|
|
46
|
+
else if (keySrc === "store")
|
|
47
|
+
add("ok", "Anthropic key: found in ~/.mnemom/code.json");
|
|
48
|
+
else
|
|
49
|
+
add("miss", "Anthropic key: none found", "export MNEMOM_CODE_ANTHROPIC_KEY=sk-ant-… (or ANTHROPIC_API_KEY), or run `mnemom code` once and accept the save prompt");
|
|
50
|
+
// ── gateway health ──
|
|
51
|
+
const host = resolveGatewayHost(env);
|
|
52
|
+
const cell = isProdGateway(env) ? "us-2/prod" : "custom";
|
|
53
|
+
const health = await probeGateway(host);
|
|
54
|
+
if (health.ok && health.verdictHeader) {
|
|
55
|
+
add("ok", `gateway: ${host} [${cell}] healthy (governance pipeline live)`);
|
|
56
|
+
}
|
|
57
|
+
else if (health.ok) {
|
|
58
|
+
add("warn", `gateway: ${host} [${cell}] responded ${health.status} but without an x-mnemom-verdict header`, "the cell is up but the governance pipeline may not be wired — traces/nudges may not appear");
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
add("warn", `gateway: ${host} [${cell}] unreachable (${health.detail})`, "check the host (MNEMOM_CODE_GATEWAY / `mnemom code config set gateway <url>`) and your network");
|
|
62
|
+
}
|
|
63
|
+
// ── Remote Control capability ──
|
|
64
|
+
if (cli) {
|
|
65
|
+
const rc = checkRcCapability(cli);
|
|
66
|
+
if (rc.ok)
|
|
67
|
+
add("ok", "Remote Control: available (node + openssl + --remote-control)");
|
|
68
|
+
else
|
|
69
|
+
add("warn", `Remote Control: unavailable — ${rc.missing.join("; ")}`, "launches fall back to terminal-only until these are in place");
|
|
70
|
+
// ── claude.ai login (informational — RC needs it) ──
|
|
71
|
+
if (cli.name === "claude") {
|
|
72
|
+
const login = claudeLoggedIn(cli.bin);
|
|
73
|
+
if (login === true)
|
|
74
|
+
add("ok", "claude.ai login: logged in");
|
|
75
|
+
else if (login === false)
|
|
76
|
+
add("info", "claude.ai login: not logged in", "Remote Control needs a claude.ai login; the terminal-only shape does not");
|
|
77
|
+
else
|
|
78
|
+
add("info", "claude.ai login: could not determine");
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
// ── render ──
|
|
82
|
+
const door = resolveAnthropicDoor(env);
|
|
83
|
+
out("mnemom code doctor");
|
|
84
|
+
out(` door: ${door}`);
|
|
85
|
+
out("");
|
|
86
|
+
for (const l of lines) {
|
|
87
|
+
out(` ${MARK[l.mark]} ${l.text}`);
|
|
88
|
+
if (l.hint)
|
|
89
|
+
out(` ↳ ${l.hint}`);
|
|
90
|
+
}
|
|
91
|
+
out("");
|
|
92
|
+
const launchReady = !lines.some((l) => l.mark === "miss");
|
|
93
|
+
if (launchReady) {
|
|
94
|
+
out(" Ready to launch: mnemom code <scenario>");
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
out(" Not launch-ready — resolve the [MISS] items above.");
|
|
98
|
+
process.exitCode = 1;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/** GET <host>/health with a short timeout; report status + whether the verdict header rode along. */
|
|
102
|
+
async function probeGateway(host) {
|
|
103
|
+
const controller = new AbortController();
|
|
104
|
+
const timer = setTimeout(() => controller.abort(), 6000);
|
|
105
|
+
try {
|
|
106
|
+
const res = await fetch(`${host}/health`, { signal: controller.signal });
|
|
107
|
+
return {
|
|
108
|
+
ok: res.status >= 200 && res.status < 300,
|
|
109
|
+
status: res.status,
|
|
110
|
+
verdictHeader: res.headers.has("x-mnemom-verdict"),
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
catch (err) {
|
|
114
|
+
return {
|
|
115
|
+
ok: false,
|
|
116
|
+
verdictHeader: false,
|
|
117
|
+
detail: err instanceof Error ? err.message : String(err),
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
finally {
|
|
121
|
+
clearTimeout(timer);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/** true / false / null(unknown) — whether the claude CLI reports a claude.ai login. */
|
|
125
|
+
function claudeLoggedIn(bin) {
|
|
126
|
+
try {
|
|
127
|
+
const res = spawnSync(bin, ["auth", "status", "--json"], { encoding: "utf8", timeout: 10_000 });
|
|
128
|
+
const text = `${res.stdout ?? ""}${res.stderr ?? ""}`;
|
|
129
|
+
if (/"loggedIn"\s*:\s*true/.test(text))
|
|
130
|
+
return true;
|
|
131
|
+
if (/"loggedIn"\s*:\s*false/.test(text))
|
|
132
|
+
return false;
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
catch {
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `mnemom code setup` + the zero-friction provisioning behind a bare
|
|
3
|
+
* `mnemom code <scenario>`.
|
|
4
|
+
*
|
|
5
|
+
* If a customer names no agent, `mnemom code` launches under a per-customer
|
|
6
|
+
* governed identity `code-<handle>`. This module makes that identity REAL in
|
|
7
|
+
* their Mnemom org: it births the agent through the gateway, claims it (so the
|
|
8
|
+
* customer owns it), and publishes a sane default coding posture — nudge/nudge:
|
|
9
|
+
* - alignment card: autonomy_mode + integrity_mode = nudge,
|
|
10
|
+
* principal.relationship = delegated_authority, coding bounded/forbidden
|
|
11
|
+
* actions, escalate-on-irreversible;
|
|
12
|
+
* - protection card: mode = nudge, thresholds 0.60/0.80/0.95, all four
|
|
13
|
+
* screen_surfaces on.
|
|
14
|
+
*
|
|
15
|
+
* All account writes are gated: interactive runs show the plan and confirm;
|
|
16
|
+
* non-interactive runs provision only with an explicit `--setup`, and otherwise
|
|
17
|
+
* launch under the unclaimed (fail-open) identity with a clear warning. A
|
|
18
|
+
* provisioning failure never blocks the launch. Reuses the existing machinery —
|
|
19
|
+
* birthThroughGateway (wrap.ts), deriveHashProof (agents.ts), claimAgent +
|
|
20
|
+
* putAlignmentCard/putProtectionCard (lib/api.ts) — rather than reinventing it.
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* The default governed-agent slug for the current customer: `code-<handle>`,
|
|
24
|
+
* where <handle> is the local-part of their mnemom login email (sanitised), or
|
|
25
|
+
* "user" when no email is available (API-key auth / opaque OAuth token).
|
|
26
|
+
*/
|
|
27
|
+
export declare function defaultAgentSlug(): string;
|
|
28
|
+
export interface EnsureAgentOptions {
|
|
29
|
+
/** The already-resolved final agent slug (what rides as x-mnemom-agent). */
|
|
30
|
+
slug: string;
|
|
31
|
+
/** The customer's Anthropic key (for the birth call + hash-proof). Never logged. */
|
|
32
|
+
anthropicKey: string;
|
|
33
|
+
/** undefined = auto, true = force (--setup), false handled by the caller (skip). */
|
|
34
|
+
setup?: boolean;
|
|
35
|
+
/** Gateway host the launch targets (birth goes to the same cell). */
|
|
36
|
+
gatewayHost: string;
|
|
37
|
+
/** Override interactivity (defaults to isInteractive()). */
|
|
38
|
+
interactive?: boolean;
|
|
39
|
+
}
|
|
40
|
+
export interface EnsureAgentResult {
|
|
41
|
+
slug: string;
|
|
42
|
+
/** true only when this call actually birthed/claimed/published. */
|
|
43
|
+
provisioned: boolean;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Ensure `slug` is a usable governed agent in the customer's org. Returns
|
|
47
|
+
* {provisioned:false} when it is already usable, when provisioning is not
|
|
48
|
+
* allowed here (non-interactive without --setup, or not logged in), or when the
|
|
49
|
+
* customer declines the confirm — in all those cases the launch continues under
|
|
50
|
+
* the given slug. THROWS only on an actual provisioning failure (birth/claim/
|
|
51
|
+
* card write) so the caller can decide whether that is fatal (`mnemom code
|
|
52
|
+
* setup`) or a warn-and-continue (a bare launch).
|
|
53
|
+
*/
|
|
54
|
+
export declare function ensureGovernedAgent(opts: EnsureAgentOptions): Promise<EnsureAgentResult>;
|
|
55
|
+
/** `mnemom code setup [--agent <slug>]` — the explicit provisioning entry point. */
|
|
56
|
+
export declare function codeSetupCommand(opts?: {
|
|
57
|
+
agent?: string;
|
|
58
|
+
}): Promise<void>;
|
|
59
|
+
/** Thrown when the agent's org has no spendable MU balance. The user-facing
|
|
60
|
+
* top-up guidance is already printed when this is thrown — callers exit quietly. */
|
|
61
|
+
export declare class MuInsufficientError extends Error {
|
|
62
|
+
readonly orgLabel: string;
|
|
63
|
+
constructor(orgLabel: string);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Ensure the customer has a Mnemom session, the way `mnemom try-me` does: if
|
|
67
|
+
* they are not signed in, offer a one-click browser sign-in (device-flow
|
|
68
|
+
* fallback for headless/SSH boxes), mentioning that a free account can be
|
|
69
|
+
* created in the same flow. Returns true if a session exists (or was just
|
|
70
|
+
* created), false if the customer declined or the run is non-interactive.
|
|
71
|
+
* Idempotent — a no-op when already authenticated.
|
|
72
|
+
*/
|
|
73
|
+
export declare function ensureMnemomSession(opts?: {
|
|
74
|
+
interactive?: boolean;
|
|
75
|
+
}): Promise<boolean>;
|
|
76
|
+
/**
|
|
77
|
+
* Enforce a positive Mnemom Units balance on the org the agent lives in.
|
|
78
|
+
* `mnemom code` has NO free tier — a determined zero/negative balance (or an org
|
|
79
|
+
* with no billing account) is BLOCKED with a portal-style top-up message.
|
|
80
|
+
* Fails OPEN on an inconclusive error (transient 5xx / network / 403), since the
|
|
81
|
+
* gateway is the real enforcement and this is a friendly pre-check; hard-blocks
|
|
82
|
+
* only on a determined depletion. Requires a session (caller ensures one first).
|
|
83
|
+
*/
|
|
84
|
+
export declare function assertMuBalance(orgId: string, orgLabel: string): Promise<void>;
|
|
85
|
+
/**
|
|
86
|
+
* The shared pre-launch preamble for `mnemom code` (and `mnemom code setup`):
|
|
87
|
+
* ensure a Mnemom session (login/sign-up), then enforce the MU balance on the
|
|
88
|
+
* org the agent lives in (default: the user's personal org). Returns the
|
|
89
|
+
* resolved org so the caller can reuse it. Throws with clear guidance when there
|
|
90
|
+
* is no session, or MuInsufficientError (message already printed) on zero MUs.
|
|
91
|
+
*/
|
|
92
|
+
export declare function ensureSessionAndBalance(opts: {
|
|
93
|
+
interactive?: boolean;
|
|
94
|
+
}): Promise<{
|
|
95
|
+
orgId: string;
|
|
96
|
+
orgLabel: string;
|
|
97
|
+
}>;
|