@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.
Files changed (48) hide show
  1. package/README.md +1 -0
  2. package/dist/commands/agents.d.ts +14 -0
  3. package/dist/commands/agents.js +100 -2
  4. package/dist/commands/card.d.ts +43 -0
  5. package/dist/commands/card.js +153 -102
  6. package/dist/commands/code-config.d.ts +17 -0
  7. package/dist/commands/code-config.js +147 -0
  8. package/dist/commands/code-doctor.d.ts +18 -0
  9. package/dist/commands/code-doctor.js +138 -0
  10. package/dist/commands/code-setup.d.ts +97 -0
  11. package/dist/commands/code-setup.js +330 -0
  12. package/dist/commands/code.d.ts +133 -0
  13. package/dist/commands/code.js +661 -0
  14. package/dist/commands/logs.js +11 -1
  15. package/dist/commands/onboard.d.ts +59 -0
  16. package/dist/commands/onboard.js +395 -0
  17. package/dist/commands/org.d.ts +13 -0
  18. package/dist/commands/org.js +63 -2
  19. package/dist/commands/protection.d.ts +10 -0
  20. package/dist/commands/protection.js +109 -0
  21. package/dist/commands/status.js +5 -0
  22. package/dist/commands/try-me.js +16 -1
  23. package/dist/commands/usage.d.ts +35 -0
  24. package/dist/commands/usage.js +265 -0
  25. package/dist/commands/wrap.d.ts +28 -0
  26. package/dist/commands/wrap.js +331 -0
  27. package/dist/index.js +315 -7
  28. package/dist/lib/agent-config.d.ts +27 -0
  29. package/dist/lib/agent-config.js +86 -0
  30. package/dist/lib/api.d.ts +139 -1
  31. package/dist/lib/api.js +132 -183
  32. package/dist/lib/cli-config.d.ts +33 -0
  33. package/dist/lib/cli-config.js +70 -0
  34. package/dist/lib/code-config.d.ts +78 -0
  35. package/dist/lib/code-config.js +281 -0
  36. package/dist/lib/code.d.ts +154 -0
  37. package/dist/lib/code.js +252 -0
  38. package/dist/lib/config.d.ts +12 -0
  39. package/dist/lib/config.js +55 -3
  40. package/dist/lib/keyed-identity.d.ts +35 -0
  41. package/dist/lib/keyed-identity.js +363 -0
  42. package/dist/lib/protection-drift.d.ts +117 -0
  43. package/dist/lib/protection-drift.js +180 -0
  44. package/dist/lib/skills.js +25 -12
  45. package/dist/lib/version-gate.d.ts +37 -0
  46. package/dist/lib/version-gate.js +84 -0
  47. package/dist/rc-proxy.mjs +341 -0
  48. package/package.json +9 -7
package/dist/lib/api.d.ts CHANGED
@@ -57,6 +57,15 @@ export interface IntegrityScore {
57
57
  verified_traces: number;
58
58
  violation_count: number;
59
59
  integrity_score: number;
60
+ /**
61
+ * MNE-596 — count of traces AAP structurally flagged but were reclassified
62
+ * as a correctly policy-refused attack (agreeing with AIP's `clear`
63
+ * verdict). Logged/visible here for transparency; NOT subtracted from
64
+ * `verified_traces` (they already count as verified) and NOT included in
65
+ * `violation_count`. Optional for backward compatibility with older API
66
+ * deployments that don't yet emit this field.
67
+ */
68
+ bounded_refusal_count?: number;
60
69
  }
61
70
  /**
62
71
  * GET /v1/traces row — components/schemas/APTrace.
@@ -103,6 +112,17 @@ export interface Trace {
103
112
  verification: {
104
113
  verified: boolean;
105
114
  violations: TraceViolation[];
115
+ /**
116
+ * MNE-596 — when set to "bounded_refusal", AAP structurally flagged a
117
+ * violation (`verified: false`) but the observer's DDR cross-check found
118
+ * AIP independently confirmed `clear` AND no bounded action was ever
119
+ * executed (a pure refusal, no tool call) — i.e. the agent was attacked
120
+ * and correctly declined. This is NOT a real violation: it must not
121
+ * render as `[VIOLATION]` and must not count against integrity_score
122
+ * (see GET /v1/integrity/:id's `bounded_refusal_count`). `violations`
123
+ * stays populated for audit/debugging — only the classification changes.
124
+ */
125
+ classification?: "bounded_refusal" | string;
106
126
  } | null;
107
127
  created_at?: string;
108
128
  }
@@ -262,7 +282,11 @@ export interface OrgFleetAgent {
262
282
  owner_email: string | null;
263
283
  last_seen: string | null;
264
284
  created_at: string;
265
- integrity_score: number;
285
+ /** MNE-460: renamed from `integrity_score` to disambiguate from reputation's
286
+ * `integrity_ratio` (a different metric). Trace-verification ratio:
287
+ * verified/total traces, lifetime, 0-1. Type-only in this CLI — never
288
+ * displayed by `fleetToRow`, so this rename carries zero behavioral risk. */
289
+ trace_verification_ratio: number;
266
290
  coverage_ratio: number;
267
291
  latest_verdict: string | null;
268
292
  active_drift_alerts: number;
@@ -329,12 +353,47 @@ export declare function claimAgent(agentId: string, body: {
329
353
  }, opts?: {
330
354
  idempotencyKey?: string;
331
355
  }): Promise<ClaimAgentResult>;
356
+ export interface MoveAgentResult {
357
+ moved: boolean;
358
+ agent_id: string;
359
+ from_org_id: string | null;
360
+ to_org_id: string | null;
361
+ }
362
+ /**
363
+ * POST /v1/agents/:id/move — role-based relocation between orgs.
364
+ *
365
+ * The role-based counterpart to claimAgent's re-claim: the server requires
366
+ * the caller to be an owner/admin of BOTH the agent's current org and
367
+ * `destOrgId` — no hash proof / agent key involved. Moving to the current
368
+ * org is an idempotent no-op (`moved: false`). An Idempotency-Key is minted
369
+ * (held across the 401-refresh retry) like every mutation.
370
+ */
371
+ export declare function moveAgent(agentId: string, destOrgId: string, opts?: {
372
+ idempotencyKey?: string;
373
+ }): Promise<MoveAgentResult>;
332
374
  /**
333
375
  * GET /v1/auth/me/personal-org — accessor for the user's personal org.
334
376
  * Idempotent: lazily provisions for legacy accounts that pre-date the
335
377
  * mnemom-api migration 161 backfill.
336
378
  */
337
379
  export declare function getMyPersonalOrg(): Promise<PersonalOrgRef>;
380
+ /**
381
+ * The org's Mnemom Units (MU) balance — `GET /v1/billing/mu` (the frozen mu
382
+ * v0.1 balance, values as decimal strings). Amounts come in both whole MU
383
+ * (`balanceMu`) and millimu (`balanceMmu`, 1 MU = 1000 mmu); the spendable
384
+ * balance is `balanceMmu - activeHoldsMmu`. `org_id` targets a specific org —
385
+ * omit to let the API resolve the caller's org. A 409 means the org has no
386
+ * billing account configured (⇒ no MUs). See mnemom-api handleBillingMu.
387
+ */
388
+ export interface MuBalance {
389
+ balanceMu: string;
390
+ balanceMmu: string;
391
+ activeHoldsMmu: string;
392
+ activeHoldsMu?: string;
393
+ effectiveMode?: string;
394
+ enforcementPausedReason?: string | null;
395
+ }
396
+ export declare function getMuBalance(orgId?: string): Promise<MuBalance>;
338
397
  export interface TeamListItem {
339
398
  team_id: string;
340
399
  name: string;
@@ -1044,4 +1103,83 @@ export interface RecipeReportResult {
1044
1103
  related_recipe_id: string;
1045
1104
  }
1046
1105
  export declare function reportRecipeFnFp(recipeId: string, input: RecipeReportInput): Promise<RecipeReportResult>;
1106
+ /**
1107
+ * One row from GET /v1/orgs/:org_id/usage/by-person — consumption grouped by
1108
+ * (person, provider, model).
1109
+ *
1110
+ * Field names mirror the wire contract in the API's `openapi.json` exactly.
1111
+ * They are NOT invented here: the first version of this client was written
1112
+ * against a guessed shape (`rows`/`tokens_consumed`/`requests` on a
1113
+ * `/v1/orgs/:id/usage` path) and every one of its tests passed because they
1114
+ * all mocked the response. `/v1/orgs/:id/usage` is a DIFFERENT, pre-existing
1115
+ * endpoint that returns per-DAY operational metrics
1116
+ * (`{ period: 'daily', days, data }`), so the command rendered `undefined`
1117
+ * against the real server. Any change here must be checked against
1118
+ * `openapi.json`, not against these types.
1119
+ *
1120
+ * Token and request totals are 64-bit integers serialized as strings.
1121
+ * Never coerce to Number — values from large orgs can exceed Number.MAX_SAFE_INTEGER.
1122
+ */
1123
+ export interface OrgUsageRow {
1124
+ /** Null for unattributed consumption — a real row, never dropped. */
1125
+ user_id: string | null;
1126
+ display_name: string;
1127
+ email: string | null;
1128
+ membership_state: string;
1129
+ /** "Unknown" when the event carried no provider. */
1130
+ provider: string;
1131
+ /** "Unknown" when the event carried no model. */
1132
+ model: string;
1133
+ /** 64-bit integer as string. */
1134
+ tokens_in: string;
1135
+ /** 64-bit integer as string. */
1136
+ tokens_out: string;
1137
+ /** 64-bit integer as string. */
1138
+ request_count: string;
1139
+ }
1140
+ /** Totals over the COMPLETE filtered result, computed before pagination. */
1141
+ export interface OrgUsageTotals {
1142
+ tokens_in: string;
1143
+ tokens_out: string;
1144
+ request_count: string;
1145
+ attributed_request_count: string;
1146
+ unattributed_request_count: string;
1147
+ /** Fraction 0–1, already rounded by the server. */
1148
+ attribution_rate: number;
1149
+ }
1150
+ export interface OrgUsageResponse {
1151
+ /** Window start, inclusive (ISO-8601, UTC midnight). */
1152
+ from: string;
1153
+ /** Window end, exclusive (ISO-8601, UTC midnight). */
1154
+ to: string;
1155
+ /** Earliest attributed event for the org, or null before the first one. */
1156
+ collection_started_at: string | null;
1157
+ data: OrgUsageRow[];
1158
+ totals: OrgUsageTotals;
1159
+ /** Opaque keyset cursor, or null on the last page. */
1160
+ next_cursor: string | null;
1161
+ }
1162
+ /** The only windows the endpoint accepts (`days` enum in `openapi.json`). */
1163
+ export declare const USAGE_ALLOWED_DAYS: readonly [7, 30, 90];
1164
+ export type UsageDays = (typeof USAGE_ALLOWED_DAYS)[number];
1165
+ export interface OrgUsageQuery {
1166
+ days?: UsageDays;
1167
+ personId?: string;
1168
+ provider?: string;
1169
+ model?: string;
1170
+ limit?: number;
1171
+ cursor?: string;
1172
+ }
1173
+ /**
1174
+ * GET /v1/orgs/:org_id/usage/by-person — consumption by person/provider/model.
1175
+ *
1176
+ * Role-gated to owner/admin/auditor; member and viewer get a real 403.
1177
+ *
1178
+ * Gated by USAGE_ATTRIBUTION_API_ENABLED, which returns **404, not 403**, when
1179
+ * off — deliberately, so a disabled endpoint is indistinguishable from one that
1180
+ * does not exist. That makes 404 ambiguous by design (flag off OR unknown org
1181
+ * OR no access), so no `notFoundLabel` is passed here: a caller must not tell
1182
+ * the user "org not found" on what is most often just the flag being off.
1183
+ */
1184
+ export declare function getOrgUsage(orgId: string, opts?: OrgUsageQuery): Promise<OrgUsageResponse>;
1047
1185
  export {};