@mnemom/mnemom 0.7.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.
Files changed (47) hide show
  1. package/LICENSE +191 -0
  2. package/README.md +123 -0
  3. package/dist/commands/agents.d.ts +15 -0
  4. package/dist/commands/agents.js +303 -0
  5. package/dist/commands/auth.d.ts +5 -0
  6. package/dist/commands/auth.js +60 -0
  7. package/dist/commands/card.d.ts +23 -0
  8. package/dist/commands/card.js +460 -0
  9. package/dist/commands/claim.d.ts +1 -0
  10. package/dist/commands/claim.js +72 -0
  11. package/dist/commands/init.d.ts +7 -0
  12. package/dist/commands/init.js +763 -0
  13. package/dist/commands/integrity.d.ts +1 -0
  14. package/dist/commands/integrity.js +49 -0
  15. package/dist/commands/license.d.ts +3 -0
  16. package/dist/commands/license.js +163 -0
  17. package/dist/commands/logs.d.ts +5 -0
  18. package/dist/commands/logs.js +73 -0
  19. package/dist/commands/migrate-config.d.ts +2 -0
  20. package/dist/commands/migrate-config.js +72 -0
  21. package/dist/commands/policy.d.ts +31 -0
  22. package/dist/commands/policy.js +543 -0
  23. package/dist/commands/register.d.ts +6 -0
  24. package/dist/commands/register.js +362 -0
  25. package/dist/commands/status.d.ts +1 -0
  26. package/dist/commands/status.js +383 -0
  27. package/dist/index.d.ts +2 -0
  28. package/dist/index.js +381 -0
  29. package/dist/lib/api.d.ts +133 -0
  30. package/dist/lib/api.js +207 -0
  31. package/dist/lib/auth.d.ts +60 -0
  32. package/dist/lib/auth.js +281 -0
  33. package/dist/lib/config.d.ts +105 -0
  34. package/dist/lib/config.js +253 -0
  35. package/dist/lib/format.d.ts +35 -0
  36. package/dist/lib/format.js +60 -0
  37. package/dist/lib/model-cache.d.ts +16 -0
  38. package/dist/lib/model-cache.js +138 -0
  39. package/dist/lib/models.d.ts +41 -0
  40. package/dist/lib/models.js +357 -0
  41. package/dist/lib/openclaw.d.ts +221 -0
  42. package/dist/lib/openclaw.js +474 -0
  43. package/dist/lib/prompt.d.ts +26 -0
  44. package/dist/lib/prompt.js +150 -0
  45. package/dist/smoltbot-shim.d.ts +2 -0
  46. package/dist/smoltbot-shim.js +7 -0
  47. package/package.json +61 -0
package/dist/index.js ADDED
@@ -0,0 +1,381 @@
1
+ #!/usr/bin/env node
2
+ import { program } from "commander";
3
+ import { initCommand } from "./commands/init.js";
4
+ import { statusCommand } from "./commands/status.js";
5
+ import { integrityCommand } from "./commands/integrity.js";
6
+ import { logsCommand } from "./commands/logs.js";
7
+ import { licenseActivateCommand, licenseStatusCommand, licenseDeactivateCommand } from "./commands/license.js";
8
+ import { cardShowCommand, cardPublishCommand, cardValidateCommand } from "./commands/card.js";
9
+ import { policyInitCommand, policyValidateCommand, policyPublishCommand, policyListCommand, policyTestCommand, policyEvaluateCommand, } from "./commands/policy.js";
10
+ import { registerCommand } from "./commands/register.js";
11
+ import { agentsListCommand, agentsRemoveCommand, agentsAddCommand, agentsDefaultCommand, agentsRekeyCommand, agentsCheckBindingCommand } from "./commands/agents.js";
12
+ import { loginCommand, logoutCommand, whoamiCommand } from "./commands/auth.js";
13
+ import { makeMigrateConfigCommand } from "./commands/migrate-config.js";
14
+ program
15
+ .name("mnemom")
16
+ .description("Transparent AI agent tracing - AAP compliant")
17
+ .version("0.6.0")
18
+ .option("--agent <name>", "Select agent by name");
19
+ program
20
+ .command("init")
21
+ .description("Initialize smoltbot for traced mode (interactive, --openclaw, or --standalone)")
22
+ .option("-y, --yes", "Skip confirmation prompts (accept defaults)")
23
+ .option("-f, --force", "Force reconfiguration even if already configured")
24
+ .option("--openclaw", "Configure using OpenClaw (requires OpenClaw installed)")
25
+ .option("--standalone", "Configure standalone (prompt for API keys directly)")
26
+ .action(async (options) => {
27
+ try {
28
+ await initCommand({
29
+ yes: options.yes,
30
+ force: options.force,
31
+ openclaw: options.openclaw,
32
+ standalone: options.standalone,
33
+ });
34
+ }
35
+ catch (error) {
36
+ console.error("Error:", error instanceof Error ? error.message : error);
37
+ process.exit(1);
38
+ }
39
+ });
40
+ program
41
+ .command("status")
42
+ .description("Show agent status and connection info")
43
+ .action(async () => {
44
+ try {
45
+ const opts = program.opts();
46
+ await statusCommand(opts.agent);
47
+ }
48
+ catch (error) {
49
+ console.error("Error:", error instanceof Error ? error.message : error);
50
+ process.exit(1);
51
+ }
52
+ });
53
+ program
54
+ .command("integrity")
55
+ .description("Display integrity score and verification stats")
56
+ .action(async () => {
57
+ try {
58
+ const opts = program.opts();
59
+ await integrityCommand(opts.agent);
60
+ }
61
+ catch (error) {
62
+ console.error("Error:", error instanceof Error ? error.message : error);
63
+ process.exit(1);
64
+ }
65
+ });
66
+ program
67
+ .command("logs")
68
+ .description("Show recent traces and actions")
69
+ .option("-l, --limit <number>", "Number of traces to show", "10")
70
+ .action(async (options) => {
71
+ try {
72
+ const globalOpts = program.opts();
73
+ const limit = parseInt(options.limit, 10);
74
+ await logsCommand({ limit: isNaN(limit) ? 10 : limit, agentName: globalOpts.agent });
75
+ }
76
+ catch (error) {
77
+ console.error("Error:", error instanceof Error ? error.message : error);
78
+ process.exit(1);
79
+ }
80
+ });
81
+ const license = program
82
+ .command("license")
83
+ .description("Enterprise license management");
84
+ license
85
+ .command("activate <jwt>")
86
+ .description("Activate an enterprise license")
87
+ .action(async (jwt) => {
88
+ try {
89
+ await licenseActivateCommand(jwt);
90
+ }
91
+ catch (error) {
92
+ console.error("Error:", error instanceof Error ? error.message : error);
93
+ process.exit(1);
94
+ }
95
+ });
96
+ license
97
+ .command("status")
98
+ .description("Show license status and details")
99
+ .action(async () => {
100
+ try {
101
+ await licenseStatusCommand();
102
+ }
103
+ catch (error) {
104
+ console.error("Error:", error instanceof Error ? error.message : error);
105
+ process.exit(1);
106
+ }
107
+ });
108
+ license
109
+ .command("deactivate")
110
+ .description("Deactivate and remove the enterprise license")
111
+ .action(async () => {
112
+ try {
113
+ await licenseDeactivateCommand();
114
+ }
115
+ catch (error) {
116
+ console.error("Error:", error instanceof Error ? error.message : error);
117
+ process.exit(1);
118
+ }
119
+ });
120
+ const cardCmd = program
121
+ .command("card")
122
+ .description("Manage alignment card");
123
+ cardCmd
124
+ .command("show")
125
+ .description("Display active alignment card")
126
+ .action(async () => {
127
+ try {
128
+ const opts = program.opts();
129
+ await cardShowCommand(opts.agent);
130
+ }
131
+ catch (error) {
132
+ console.error("Error:", error instanceof Error ? error.message : error);
133
+ process.exit(1);
134
+ }
135
+ });
136
+ cardCmd
137
+ .command("publish")
138
+ .argument("<file>", "Path to card JSON file")
139
+ .description("Publish alignment card from JSON file")
140
+ .action(async (file) => {
141
+ try {
142
+ const opts = program.opts();
143
+ await cardPublishCommand(file, opts.agent);
144
+ }
145
+ catch (error) {
146
+ console.error("Error:", error instanceof Error ? error.message : error);
147
+ process.exit(1);
148
+ }
149
+ });
150
+ cardCmd
151
+ .command("validate")
152
+ .argument("<file>", "Path to card JSON file")
153
+ .description("Validate card JSON locally")
154
+ .action(async (file) => {
155
+ try {
156
+ await cardValidateCommand(file);
157
+ }
158
+ catch (error) {
159
+ console.error("Error:", error instanceof Error ? error.message : error);
160
+ process.exit(1);
161
+ }
162
+ });
163
+ const policyCmd = program
164
+ .command("policy")
165
+ .description("Manage policy engine");
166
+ policyCmd
167
+ .command("init")
168
+ .description("Scaffold a policy.json template")
169
+ .action(async () => {
170
+ try {
171
+ await policyInitCommand();
172
+ }
173
+ catch (error) {
174
+ console.error("Error:", error instanceof Error ? error.message : error);
175
+ process.exit(1);
176
+ }
177
+ });
178
+ policyCmd
179
+ .command("validate")
180
+ .argument("<file>", "Path to policy JSON file")
181
+ .description("Validate policy locally")
182
+ .action(async (file) => {
183
+ try {
184
+ await policyValidateCommand(file);
185
+ }
186
+ catch (error) {
187
+ console.error("Error:", error instanceof Error ? error.message : error);
188
+ process.exit(1);
189
+ }
190
+ });
191
+ policyCmd
192
+ .command("publish")
193
+ .argument("<file>", "Path to policy JSON file")
194
+ .description("Validate and publish policy to API")
195
+ .action(async (file) => {
196
+ try {
197
+ const opts = program.opts();
198
+ await policyPublishCommand(file, opts.agent);
199
+ }
200
+ catch (error) {
201
+ console.error("Error:", error instanceof Error ? error.message : error);
202
+ process.exit(1);
203
+ }
204
+ });
205
+ policyCmd
206
+ .command("list")
207
+ .description("List active policy for current agent")
208
+ .action(async () => {
209
+ try {
210
+ const opts = program.opts();
211
+ await policyListCommand(opts.agent);
212
+ }
213
+ catch (error) {
214
+ console.error("Error:", error instanceof Error ? error.message : error);
215
+ process.exit(1);
216
+ }
217
+ });
218
+ policyCmd
219
+ .command("test")
220
+ .argument("<file>", "Path to policy JSON file")
221
+ .option("--against-traces", "Test against historical traces")
222
+ .description("Dry-run policy against historical traces")
223
+ .action(async (file) => {
224
+ try {
225
+ const opts = program.opts();
226
+ await policyTestCommand(file, opts.agent);
227
+ }
228
+ catch (error) {
229
+ console.error("Error:", error instanceof Error ? error.message : error);
230
+ process.exit(1);
231
+ }
232
+ });
233
+ policyCmd
234
+ .command("evaluate")
235
+ .argument("<file>", "Path to policy JSON file")
236
+ .option("--card <file>", "Path to alignment card JSON file")
237
+ .option("--tools <tools>", "Comma-separated list of tool names")
238
+ .option("--tool-manifest <file>", "Path to tool manifest JSON file")
239
+ .option("--strict", "Exit with code 1 on warnings (not just failures)")
240
+ .description("Evaluate policy against tools locally (for CI/CD)")
241
+ .action(async (file, options) => {
242
+ try {
243
+ await policyEvaluateCommand(file, options);
244
+ }
245
+ catch (error) {
246
+ console.error("Error:", error instanceof Error ? error.message : error);
247
+ process.exit(1);
248
+ }
249
+ });
250
+ program
251
+ .command("register <name>")
252
+ .description("Register a new named agent")
253
+ .option("--openclaw", "Configure using OpenClaw")
254
+ .option("--standalone", "Configure standalone mode")
255
+ .option("--set-default", "Set as default agent")
256
+ .action(async (name, options) => {
257
+ try {
258
+ await registerCommand(name, {
259
+ openclaw: options.openclaw,
260
+ standalone: options.standalone,
261
+ setDefault: options.setDefault,
262
+ });
263
+ }
264
+ catch (error) {
265
+ console.error("Error:", error instanceof Error ? error.message : error);
266
+ process.exit(1);
267
+ }
268
+ });
269
+ const agentsCmd = program
270
+ .command("agents")
271
+ .description("List and manage registered agents");
272
+ agentsCmd
273
+ .action(async () => {
274
+ try {
275
+ await agentsListCommand();
276
+ }
277
+ catch (error) {
278
+ console.error("Error:", error instanceof Error ? error.message : error);
279
+ process.exit(1);
280
+ }
281
+ });
282
+ agentsCmd
283
+ .command("remove <name>")
284
+ .description("Remove a registered agent")
285
+ .action(async (name) => {
286
+ try {
287
+ await agentsRemoveCommand(name);
288
+ }
289
+ catch (error) {
290
+ console.error("Error:", error instanceof Error ? error.message : error);
291
+ process.exit(1);
292
+ }
293
+ });
294
+ agentsCmd
295
+ .command("add <name-or-id>")
296
+ .description("Register an existing API agent in local config")
297
+ .option("--alias <alias>", "Local alias name (default: agent's API name)")
298
+ .action(async (nameOrId, options) => {
299
+ try {
300
+ await agentsAddCommand(nameOrId, options.alias);
301
+ }
302
+ catch (error) {
303
+ console.error("Error:", error instanceof Error ? error.message : error);
304
+ process.exit(1);
305
+ }
306
+ });
307
+ agentsCmd
308
+ .command("default <name>")
309
+ .description("Set the default agent")
310
+ .action(async (name) => {
311
+ try {
312
+ await agentsDefaultCommand(name);
313
+ }
314
+ catch (error) {
315
+ console.error("Error:", error instanceof Error ? error.message : error);
316
+ process.exit(1);
317
+ }
318
+ });
319
+ agentsCmd
320
+ .command("rekey [name]")
321
+ .description("Re-bind an agent to a new provider API key (key hashed locally, never transmitted)")
322
+ .action(async (name) => {
323
+ try {
324
+ await agentsRekeyCommand(name);
325
+ }
326
+ catch (error) {
327
+ console.error("Error:", error instanceof Error ? error.message : error);
328
+ process.exit(1);
329
+ }
330
+ });
331
+ agentsCmd
332
+ .command("check-binding [name]")
333
+ .description("Verify that a provider API key is bound to an agent (key hashed locally, never transmitted)")
334
+ .action(async (name) => {
335
+ try {
336
+ await agentsCheckBindingCommand(name);
337
+ }
338
+ catch (error) {
339
+ console.error("Error:", error instanceof Error ? error.message : error);
340
+ process.exit(1);
341
+ }
342
+ });
343
+ program
344
+ .command("login")
345
+ .description("Authenticate with your Mnemom account")
346
+ .option("--no-browser", "Use email/password prompt instead of browser")
347
+ .action(async (options) => {
348
+ try {
349
+ await loginCommand({ noBrowser: options.browser === false });
350
+ }
351
+ catch (error) {
352
+ console.error("Error:", error instanceof Error ? error.message : error);
353
+ process.exit(1);
354
+ }
355
+ });
356
+ program
357
+ .command("logout")
358
+ .description("Clear stored authentication credentials")
359
+ .action(async () => {
360
+ try {
361
+ await logoutCommand();
362
+ }
363
+ catch (error) {
364
+ console.error("Error:", error instanceof Error ? error.message : error);
365
+ process.exit(1);
366
+ }
367
+ });
368
+ program
369
+ .command("whoami")
370
+ .description("Show current authentication status")
371
+ .action(async () => {
372
+ try {
373
+ await whoamiCommand();
374
+ }
375
+ catch (error) {
376
+ console.error("Error:", error instanceof Error ? error.message : error);
377
+ process.exit(1);
378
+ }
379
+ });
380
+ program.addCommand(makeMigrateConfigCommand());
381
+ program.parse();
@@ -0,0 +1,133 @@
1
+ export declare const API_BASE: string;
2
+ export interface Agent {
3
+ id: string;
4
+ gateway: string;
5
+ last_seen: string | null;
6
+ claimed: boolean;
7
+ email?: string;
8
+ created_at: string;
9
+ }
10
+ export interface IntegrityScore {
11
+ agent_id: string;
12
+ score: number;
13
+ total_traces: number;
14
+ verified: number;
15
+ violations: number;
16
+ last_updated: string;
17
+ }
18
+ export interface Trace {
19
+ id: string;
20
+ agent_id: string;
21
+ timestamp: string;
22
+ action: string;
23
+ verified: boolean;
24
+ reasoning?: string;
25
+ tool_name?: string;
26
+ tool_input?: Record<string, unknown>;
27
+ }
28
+ export interface ApiError {
29
+ error: string;
30
+ message: string;
31
+ }
32
+ export declare function postApi<T>(endpoint: string, body: unknown): Promise<T>;
33
+ export declare function verifyBinding(agentId: string, keyHash: string): Promise<{
34
+ bound: boolean;
35
+ key_prefix: string | null;
36
+ }>;
37
+ export declare function getAgent(id: string): Promise<Agent>;
38
+ export interface AgentListItem {
39
+ id: string;
40
+ name: string | null;
41
+ email: string | null;
42
+ created_at: string;
43
+ last_seen: string | null;
44
+ containment_status: string | null;
45
+ key_prefix?: string | null;
46
+ }
47
+ export declare function listAgents(): Promise<AgentListItem[]>;
48
+ /**
49
+ * Look up an agent in the authenticated user's account by name.
50
+ * Tries exact match first, then single partial match.
51
+ * Throws if multiple agents partially match (ambiguous).
52
+ * Returns null if no match found.
53
+ * Note: capped at 100 agents by listAgents().
54
+ */
55
+ export declare function getAgentByName(name: string): Promise<AgentListItem | null>;
56
+ export declare function getIntegrity(id: string): Promise<IntegrityScore>;
57
+ export declare function getTraces(id: string, limit?: number): Promise<Trace[]>;
58
+ export interface AlignmentCard {
59
+ card_id?: string;
60
+ version?: string;
61
+ issued_at?: string;
62
+ expires_at?: string;
63
+ principal?: {
64
+ name?: string;
65
+ type?: string;
66
+ organization?: string;
67
+ };
68
+ values?: {
69
+ declared?: string[];
70
+ definitions?: Record<string, string>;
71
+ };
72
+ autonomy_envelope?: {
73
+ bounded_actions?: string[];
74
+ forbidden_actions?: string[];
75
+ escalation_triggers?: Array<{
76
+ condition: string;
77
+ action?: string;
78
+ }>;
79
+ };
80
+ audit_commitment?: {
81
+ log_level?: string;
82
+ retention_days?: number;
83
+ access_policy?: string;
84
+ };
85
+ extensions?: Record<string, unknown>;
86
+ [key: string]: unknown;
87
+ }
88
+ export interface CardResponse {
89
+ card_id: string;
90
+ agent_id: string;
91
+ card_json: AlignmentCard;
92
+ created_at: string;
93
+ updated_at: string;
94
+ }
95
+ export declare function getCard(agentId: string): Promise<CardResponse | null>;
96
+ export declare function updateCard(agentId: string, cardJson: AlignmentCard): Promise<{
97
+ updated: boolean;
98
+ card_id: string;
99
+ }>;
100
+ export declare function reverifyAgent(agentId: string): Promise<{
101
+ reverified: number;
102
+ }>;
103
+ export interface PolicyResponse {
104
+ id: string;
105
+ name: string;
106
+ description: string | null;
107
+ policy_json: Record<string, unknown>;
108
+ version: number;
109
+ created_by: string;
110
+ created_at: string;
111
+ }
112
+ export interface PolicyListResponse {
113
+ agent_id: string;
114
+ policy: PolicyResponse | null;
115
+ }
116
+ export declare function getPolicy(agentId: string): Promise<PolicyListResponse | null>;
117
+ export declare function publishPolicy(agentId: string, policyJson: Record<string, unknown>): Promise<{
118
+ id: string;
119
+ version: number;
120
+ created: boolean;
121
+ }>;
122
+ export declare function testPolicyHistorical(agentId: string, policyJson: Record<string, unknown>, limit?: number): Promise<{
123
+ agent_id: string;
124
+ policy_name: string;
125
+ total_traces: number;
126
+ results: any[];
127
+ summary: {
128
+ pass: number;
129
+ warn: number;
130
+ fail: number;
131
+ skipped: number;
132
+ };
133
+ }>;