@nexusm/sdk 2.0.0 → 4.0.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 CHANGED
@@ -165,10 +165,13 @@ const graph = await nexus.knowledge.query({
165
165
 
166
166
  | Method | Description |
167
167
  |--------|-------------|
168
- | `createEntity(data)` | Create a new entity in the knowledge graph |
169
- | `listEntities(params?)` | List entities with optional filtering |
168
+ | `listEntities(params)` | List entities for a user (`user_id` required) |
170
169
  | `query(request)` | BFS graph traversal from a named entity |
171
- | `extract(request)` | Extract entities and relationships from text |
170
+ | `extract(request)` | Extract entities and relationships from text (also how entities are created) |
171
+
172
+ > v3.0.0: `createEntity()` was removed — the backend has no
173
+ > `POST /knowledge/entities` route (the SDK method 404'd at runtime).
174
+ > Entities are created via `extract()`.
172
175
 
173
176
  ### Activity Service
174
177
 
@@ -202,14 +205,14 @@ Tenant profile and usage management. Identity is derived from the API key.
202
205
  const tenant = await nexus.tenants.me();
203
206
  console.log(tenant.name, tenant.tier);
204
207
 
205
- const usage = await nexus.tenants.usage();
206
- console.log('Memories:', usage.memories_count);
208
+ const usage = await nexus.tenants.usage('week');
209
+ console.log(`API calls: ${usage.api_calls} (${usage.success_rate}% ok)`);
207
210
  ```
208
211
 
209
212
  | Method | Description |
210
213
  |--------|-------------|
211
- | `me()` | Retrieve the current tenant profile |
212
- | `usage()` | Retrieve resource usage statistics |
214
+ | `me()` | Retrieve the current tenant profile (flat counts + `quota_remaining`) |
215
+ | `usage(period?)` | Usage statistics for `'day'` (default) / `'week'` / `'month'` — 13-field `UsageStats` |
213
216
 
214
217
  ## Error Handling
215
218
 
package/dist/index.d.mts CHANGED
@@ -802,13 +802,26 @@ declare class ContextService extends BaseService {
802
802
  type MemoryType = 'episodic' | 'semantic' | 'procedural';
803
803
  /**
804
804
  * A memory record stored in the Nexus platform.
805
- * Represents a single piece of user knowledge managed by Mem0.
805
+ *
806
+ * Mirrors backend `MemoryResponse` (schemas/memory.py, 14 fields).
807
+ *
808
+ * v4.0.0 (memory-conversation-contract-reconciliation): adds the
809
+ * compound-identifier trio (`memory_id` / `tenant_id` / `agent_id`) and the
810
+ * US-035 temporal-validity window (`valid_from` / `valid_until` /
811
+ * `valid_until_source`) — all emitted by the backend but previously missing
812
+ * from this type (readers got `undefined`).
806
813
  */
807
814
  interface Memory {
815
+ /** Compound memory ID ("tenant::user::uuid") — needed for multi-tenant ops */
816
+ memory_id: string;
808
817
  /** Unique memory identifier (UUID) */
809
818
  id: string;
819
+ /** Tenant identifier */
820
+ tenant_id: string;
810
821
  /** User ID that owns this memory */
811
822
  user_id: string;
823
+ /** Originating agent (null when not agent-written) */
824
+ agent_id?: string | null;
812
825
  /** Memory content text */
813
826
  content: string;
814
827
  /** Classification of the memory */
@@ -816,7 +829,13 @@ interface Memory {
816
829
  /** Additional metadata key-value pairs */
817
830
  metadata?: Record<string, unknown>;
818
831
  /** Relevance score (present in search results) */
819
- score?: number;
832
+ score?: number | null;
833
+ /** Start of the temporal validity window (inclusive; server-managed) */
834
+ valid_from?: string | null;
835
+ /** End of the temporal validity window (exclusive; null = permanent) */
836
+ valid_until?: string | null;
837
+ /** Provenance of valid_until (permanent / extracted / sdk_provided / ...) */
838
+ valid_until_source?: string | null;
820
839
  /** Timestamp when the memory was created (ISO 8601) */
821
840
  created_at: string;
822
841
  /** Timestamp when the memory was last updated (ISO 8601) */
@@ -1097,10 +1116,17 @@ declare class MemoryService extends BaseService {
1097
1116
  /**
1098
1117
  * @nexusm/sdk - Conversation Types
1099
1118
  *
1100
- * Type definitions for the Conversation Service powered by Zep OSS.
1119
+ * Type definitions for the Conversation Service.
1101
1120
  * Manages conversation history, messages, and auto-generated summaries.
1102
1121
  *
1103
- * Based on Nexus API v2.0 OpenAPI specification.
1122
+ * v4.0.0 BREAKING (memory-conversation-contract-reconciliation, 2026-06-11):
1123
+ * canonical = backend Pydantic response models (`schemas/conversation.py`)
1124
+ * serialized wire names. The previous shapes were drifted: nested
1125
+ * `{data, pagination}` containers never existed on the wire (backend lists
1126
+ * are FLAT), the conversation identifier wire key is `conversation_id` (the
1127
+ * old `session_id` was a phantom), `ConversationDetail` described a response
1128
+ * no endpoint emits, and `ConversationSummary` declared phantom
1129
+ * `key_points`/`generated_at` while missing the real count fields.
1104
1130
  */
1105
1131
  /** Valid message roles in a conversation */
1106
1132
  type MessageRole = 'user' | 'assistant' | 'system' | 'tool';
@@ -1108,17 +1134,29 @@ type MessageRole = 'user' | 'assistant' | 'system' | 'tool';
1108
1134
  type ConversationStatus = 'active' | 'archived' | 'deleted';
1109
1135
  /**
1110
1136
  * A conversation session between a user and an AI agent.
1111
- * Managed by Zep OSS for temporal graph and auto-summary.
1137
+ *
1138
+ * GET /conversations/{conversation_id} — mirrors backend
1139
+ * `ConversationResponse` (11 fields, flat).
1140
+ *
1141
+ * v4.0.0 BREAKING: `session_id` → `conversation_id` (the real wire key —
1142
+ * backend field `compound_session_id` serializes via alias); adds
1143
+ * `tenant_id` / `agent_id` / `status` (previously missing).
1112
1144
  */
1113
1145
  interface Conversation {
1114
1146
  /** Unique conversation identifier (UUID) */
1115
1147
  id: string;
1148
+ /** Compound session ID ("tenant::user::session") — the wire key */
1149
+ conversation_id: string;
1150
+ /** Tenant identifier */
1151
+ tenant_id: string;
1116
1152
  /** User ID that owns this conversation */
1117
1153
  user_id: string;
1118
- /** Session identifier for the conversation */
1119
- session_id?: string;
1154
+ /** Originating agent (null when not agent-created) */
1155
+ agent_id?: string | null;
1156
+ /** Conversation status (e.g. active / archived) */
1157
+ status: string;
1120
1158
  /** Auto-generated conversation summary */
1121
- summary?: string;
1159
+ summary?: string | null;
1122
1160
  /** Total number of messages in the conversation */
1123
1161
  message_count: number;
1124
1162
  /** Additional metadata key-value pairs */
@@ -1141,20 +1179,28 @@ interface ConversationCreate {
1141
1179
  /** Additional metadata key-value pairs */
1142
1180
  metadata?: Record<string, unknown>;
1143
1181
  }
1144
- /**
1145
- * Conversation with its messages included.
1146
- * Returned when include_messages=true.
1147
- */
1148
- interface ConversationDetail extends Conversation {
1149
- /** Messages in the conversation */
1150
- messages: Message[];
1151
- }
1152
1182
  /**
1153
1183
  * A single message within a conversation.
1184
+ *
1185
+ * Mirrors backend `MessageResponse` (11 fields).
1186
+ *
1187
+ * v4.0.0 BREAKING: adds `message_id` / `conversation_id` /
1188
+ * `conversation_compound_id` / `tenant_id` / `user_id` correlation fields
1189
+ * (previously missing from the SDK type while present on the wire).
1154
1190
  */
1155
1191
  interface Message {
1156
1192
  /** Unique message identifier (UUID) */
1157
1193
  id: string;
1194
+ /** Compound message ID */
1195
+ message_id: string;
1196
+ /** Owning conversation UUID (NOT the compound id — see conversation_compound_id) */
1197
+ conversation_id: string;
1198
+ /** Owning conversation compound ID ("tenant::user::session") */
1199
+ conversation_compound_id: string;
1200
+ /** Tenant identifier */
1201
+ tenant_id: string;
1202
+ /** User identifier */
1203
+ user_id: string;
1158
1204
  /** Message role (user, assistant, system, or tool) */
1159
1205
  role: MessageRole;
1160
1206
  /** Message content text */
@@ -1162,7 +1208,7 @@ interface Message {
1162
1208
  /** Additional metadata key-value pairs */
1163
1209
  metadata?: Record<string, unknown>;
1164
1210
  /** Message sequence number within the conversation */
1165
- sequence?: number;
1211
+ sequence: number;
1166
1212
  /** Timestamp when the message was created (ISO 8601) */
1167
1213
  created_at: string;
1168
1214
  }
@@ -1182,49 +1228,67 @@ interface MessageCreate {
1182
1228
  /**
1183
1229
  * Paginated list of conversations.
1184
1230
  *
1185
- * GET /conversations?user_id=...
1231
+ * GET /conversations?user_id=... — mirrors backend
1232
+ * `ConversationListResponse` (FLAT container).
1233
+ *
1234
+ * v4.0.0 BREAKING: was nested `{data, pagination:{total, limit, offset,
1235
+ * has_more}}` — that shape never existed on the wire.
1186
1236
  */
1187
1237
  interface ConversationList {
1188
1238
  /** Array of conversation records */
1189
- data: Conversation[];
1190
- /** Pagination metadata */
1191
- pagination: {
1192
- /** Total number of conversations */
1193
- total: number;
1194
- /** Current page size limit */
1195
- limit: number;
1196
- /** Current offset */
1197
- offset: number;
1198
- /** Whether more results exist */
1199
- has_more: boolean;
1200
- };
1239
+ conversations: Conversation[];
1240
+ /** Total number of conversations */
1241
+ total_count: number;
1242
+ /** Current page size limit */
1243
+ limit: number;
1244
+ /** Current offset */
1245
+ offset: number;
1246
+ /** Whether more results exist */
1247
+ has_next: boolean;
1201
1248
  }
1202
1249
  /**
1203
1250
  * Paginated list of messages within a conversation.
1204
1251
  *
1205
- * GET /conversations/:conversation_id/messages
1252
+ * GET /conversations/:conversation_id/messages — mirrors backend
1253
+ * `MessageListResponse` (FLAT container).
1254
+ *
1255
+ * v4.0.0 BREAKING: was `{data, has_more}` — missing
1256
+ * total_count/limit/offset and using a phantom container key.
1206
1257
  */
1207
1258
  interface MessageList {
1208
1259
  /** Array of message records */
1209
- data: Message[];
1210
- /** Whether more messages exist before the current page */
1211
- has_more: boolean;
1260
+ messages: Message[];
1261
+ /** Total number of messages */
1262
+ total_count: number;
1263
+ /** Current page size limit */
1264
+ limit: number;
1265
+ /** Current offset */
1266
+ offset: number;
1267
+ /** Whether more messages exist */
1268
+ has_next: boolean;
1212
1269
  }
1213
1270
  /**
1214
1271
  * Auto-generated summary of a conversation.
1215
- * Generated by Zep OSS temporal graph analysis.
1216
1272
  *
1217
- * GET /conversations/:conversation_id/summary
1273
+ * GET /conversations/:conversation_id/summary — mirrors backend
1274
+ * `SummaryResponse` (5 fields).
1275
+ *
1276
+ * v4.0.0 BREAKING: the previous shape declared phantom `key_points[]` /
1277
+ * `generated_at`; the backend emits message counts + `created_at`. The wire
1278
+ * id key is `conversation_id` (unified 2026-06-11 — the endpoint previously
1279
+ * emitted `compound_session_id`, an internal third id variant).
1218
1280
  */
1219
1281
  interface ConversationSummary {
1220
- /** Conversation identifier (UUID) */
1282
+ /** Compound conversation ID (same key as Conversation.conversation_id) */
1221
1283
  conversation_id: string;
1222
- /** Generated summary text */
1223
- summary?: string;
1224
- /** Key points extracted from the conversation */
1225
- key_points?: string[];
1226
- /** Timestamp when the summary was generated (ISO 8601) */
1227
- generated_at: string;
1284
+ /** Generated summary text (null until first summary) */
1285
+ summary?: string | null;
1286
+ /** Number of messages already folded into the summary */
1287
+ summary_message_count: number;
1288
+ /** Total number of messages in the conversation */
1289
+ message_count: number;
1290
+ /** Timestamp when the conversation was created (ISO 8601) */
1291
+ created_at: string;
1228
1292
  }
1229
1293
 
1230
1294
  /**
@@ -1301,13 +1365,17 @@ declare class ConversationService extends BaseService {
1301
1365
  */
1302
1366
  list(params?: ConversationListParams, options?: RequestOptions): Promise<ConversationList>;
1303
1367
  /**
1304
- * Retrieve a conversation with its messages included.
1368
+ * Retrieve a conversation.
1369
+ *
1370
+ * v4.0.0 BREAKING: returns `Conversation` — the backend response has no
1371
+ * `messages` array (the previous `ConversationDetail` shape was a
1372
+ * phantom). Fetch messages via {@link getMessages}.
1305
1373
  *
1306
- * @param conversationId - UUID of the conversation to retrieve.
1307
- * @returns Conversation detail including the full message list.
1374
+ * @param conversationId - Compound conversation ID to retrieve.
1375
+ * @returns The conversation record.
1308
1376
  * @throws {ApiError} 404 if the conversation does not exist.
1309
1377
  */
1310
- get(conversationId: string, options?: RequestOptions): Promise<ConversationDetail>;
1378
+ get(conversationId: string, options?: RequestOptions): Promise<Conversation>;
1311
1379
  /**
1312
1380
  * Add a message to an existing conversation.
1313
1381
  *
@@ -1504,26 +1572,15 @@ interface GraphQueryResponse {
1504
1572
  */
1505
1573
 
1506
1574
  /**
1507
- * Request payload for creating a new knowledge entity.
1575
+ * Parameters for listing knowledge entities.
1508
1576
  *
1509
- * POST /knowledge/entities
1510
- */
1511
- interface EntityCreate {
1512
- /** Entity display name */
1513
- name: string;
1514
- /** Entity type classification (e.g., Person, Organization, Concept) */
1515
- entity_type: string;
1516
- /** Entity description */
1517
- description?: string;
1518
- /** Additional entity properties */
1519
- properties?: Record<string, unknown>;
1520
- }
1521
- /**
1522
- * Parameters for listing knowledge entities with optional filtering.
1577
+ * v3.0.0 BREAKING: `user_id` is required — the backend (and OpenAPI) demand
1578
+ * it (`Query(..., min_length=1)`); the previous optional typing let calls
1579
+ * compile that 422'd at runtime.
1523
1580
  */
1524
1581
  interface EntityListParams {
1525
- /** Filter entities by user ID (owner) */
1526
- user_id?: string;
1582
+ /** Entity owner user ID (required by the backend) */
1583
+ user_id: string;
1527
1584
  /** Filter by entity type classification */
1528
1585
  entity_type?: string;
1529
1586
  /** Maximum number of results to return */
@@ -1534,9 +1591,11 @@ interface EntityListParams {
1534
1591
  /**
1535
1592
  * Service for managing the knowledge graph via Fast GraphRAG.
1536
1593
  *
1537
- * Provides entity CRUD, BFS graph traversal queries, and automatic
1594
+ * Provides entity listing, BFS graph traversal queries, and automatic
1538
1595
  * entity/relationship extraction from unstructured text. Supports
1539
1596
  * both public (agent-owned) and private (user-owned) knowledge.
1597
+ * (v3.0.0: entity creation was removed — the backend has no
1598
+ * POST /knowledge/entities route; entities are created via extract().)
1540
1599
  *
1541
1600
  * @example
1542
1601
  * ```typescript
@@ -1559,19 +1618,12 @@ interface EntityListParams {
1559
1618
  */
1560
1619
  declare class KnowledgeService extends BaseService {
1561
1620
  /**
1562
- * Create a new knowledge entity in the graph.
1621
+ * List knowledge entities for a user with optional filtering.
1563
1622
  *
1564
- * @param data - Entity creation payload including name, type, and optional description/properties.
1565
- * @returns The newly created entity with generated entity_id.
1566
- */
1567
- createEntity(data: EntityCreate, options?: RequestOptions): Promise<KnowledgeEntity>;
1568
- /**
1569
- * List knowledge entities with optional filtering.
1570
- *
1571
- * @param params - Optional filters for user_id, entity_type, and pagination controls.
1623
+ * @param params - Filters: required user_id (backend-enforced), optional entity_type and pagination controls.
1572
1624
  * @returns Paginated list of knowledge entities.
1573
1625
  */
1574
- listEntities(params?: EntityListParams, options?: RequestOptions): Promise<EntityListResponse>;
1626
+ listEntities(params: EntityListParams, options?: RequestOptions): Promise<EntityListResponse>;
1575
1627
  /**
1576
1628
  * Query the knowledge graph using BFS traversal.
1577
1629
  *
@@ -1753,39 +1805,43 @@ declare class ActivityService extends BaseService {
1753
1805
  * Supports multi-tenant isolation, API key management,
1754
1806
  * quota tracking, and usage statistics.
1755
1807
  *
1756
- * Based on Nexus API v2.0 OpenAPI specification.
1808
+ * v3.0.0 BREAKING (tenant-contract-reconciliation, 2026-06-10): canonical =
1809
+ * backend Pydantic response models (`schemas/tenant.py`). The previous shapes
1810
+ * were drifted: `Tenant` had a phantom nested `usage` object (the wire is
1811
+ * flat), `UsageStats` declared 3 phantom fields and missed 11 real ones, and
1812
+ * `ApiKeyCreate` used the phantom request field `expires_days` (the wire is
1813
+ * `expires_in_days` — the old name was silently dropped by the backend,
1814
+ * creating never-expiring keys).
1757
1815
  */
1758
1816
  /** Available tenant subscription tiers */
1759
1817
  type TenantTier = 'free' | 'starter' | 'pro' | 'enterprise';
1760
- /** API Key permission scopes */
1761
- type ApiKeyScope = 'read' | 'write' | 'admin';
1762
1818
  /**
1763
1819
  * Tenant quotas configuration defining resource limits.
1820
+ *
1821
+ * The backend serializes a free-form object; the keys below are the
1822
+ * well-known ones. Unknown keys are preserved via the index signature.
1764
1823
  */
1765
1824
  interface TenantQuotas {
1766
1825
  /** Maximum number of memories allowed */
1767
1826
  max_memories?: number;
1768
1827
  /** Maximum number of conversations allowed */
1769
1828
  max_conversations?: number;
1829
+ /** Maximum number of knowledge graph nodes allowed */
1830
+ max_graph_nodes?: number;
1770
1831
  /** Maximum API calls per day */
1771
1832
  max_api_calls_per_day?: number;
1772
- }
1773
- /**
1774
- * Current resource usage counts for a tenant.
1775
- */
1776
- interface TenantUsage {
1777
- /** Current number of memories stored */
1778
- memories_count?: number;
1779
- /** Current number of conversations */
1780
- conversations_count?: number;
1781
- /** API calls made today */
1782
- api_calls_today?: number;
1833
+ /** Forward-compatible: any additional quota dimensions */
1834
+ [key: string]: unknown;
1783
1835
  }
1784
1836
  /**
1785
1837
  * A tenant (organization) on the Nexus platform.
1786
1838
  * Each tenant has isolated data and configurable quotas.
1787
1839
  *
1788
- * GET /tenants/me
1840
+ * GET /tenants/me — mirrors backend `TenantInfoResponse` (flat shape).
1841
+ *
1842
+ * v3.0.0 BREAKING: usage counts are FLAT top-level fields (the nested
1843
+ * `usage` object never existed on the wire); adds `quota_remaining` and
1844
+ * `graph_nodes_count` (previously missing).
1789
1845
  */
1790
1846
  interface Tenant {
1791
1847
  /** Unique tenant identifier (UUID) */
@@ -1795,17 +1851,28 @@ interface Tenant {
1795
1851
  /** Subscription tier */
1796
1852
  tier: TenantTier;
1797
1853
  /** Resource quotas */
1798
- quotas?: TenantQuotas;
1799
- /** Current resource usage */
1800
- usage?: TenantUsage;
1854
+ quotas: TenantQuotas;
1855
+ /** Remaining headroom per quota dimension */
1856
+ quota_remaining: Record<string, number>;
1801
1857
  /** Timestamp when the tenant was created (ISO 8601) */
1802
1858
  created_at: string;
1859
+ /** Current number of memories stored (flat — not nested under `usage`) */
1860
+ memories_count: number;
1861
+ /** Current number of conversations (flat — not nested under `usage`) */
1862
+ conversations_count: number;
1863
+ /** Current number of knowledge graph nodes */
1864
+ graph_nodes_count: number;
1803
1865
  }
1804
1866
  /**
1805
1867
  * An API key for authenticating with the Nexus platform.
1806
1868
  * The full key value is only returned once at creation time.
1807
1869
  *
1808
1870
  * GET /tenants/me/api-keys
1871
+ *
1872
+ * v3.0.0: `scopes` is a free-form string array documenting backend reality —
1873
+ * known values are `"read"`, `"write"`, `"admin"` and the `"*"` wildcard
1874
+ * (the backend authorizes via `scope in scopes or "*" in scopes`). The old
1875
+ * `ApiKeyScope` enum could not represent `"*"`, the actual default.
1809
1876
  */
1810
1877
  interface ApiKey {
1811
1878
  /** Unique API key identifier (UUID) */
@@ -1814,8 +1881,8 @@ interface ApiKey {
1814
1881
  key_prefix: string;
1815
1882
  /** Human-readable name for the API key */
1816
1883
  name: string;
1817
- /** Permission scopes granted to this key */
1818
- scopes: ApiKeyScope[];
1884
+ /** Permission scopes granted to this key (known values: read, write, admin, "*") */
1885
+ scopes: string[];
1819
1886
  /** Expiration timestamp (null = never expires) (ISO 8601) */
1820
1887
  expires_at?: string | null;
1821
1888
  /** Last time this key was used (ISO 8601) */
@@ -1826,23 +1893,28 @@ interface ApiKey {
1826
1893
  /**
1827
1894
  * Request payload for creating a new API key.
1828
1895
  *
1829
- * POST /tenants/me/api-keys
1896
+ * POST /tenants/me/api-keys — mirrors backend `ApiKeyCreate`.
1897
+ *
1898
+ * v3.0.0 BREAKING: `expires_days` → `expires_in_days` (the backend request
1899
+ * field). The old name was silently ignored by the backend (no
1900
+ * `extra=forbid`), so keys created through the SDK never expired.
1830
1901
  */
1831
1902
  interface ApiKeyCreate {
1832
- /** Human-readable name for the API key (1-100 characters) */
1903
+ /** Human-readable name for the API key (1-255 characters) */
1833
1904
  name: string;
1834
1905
  /**
1835
- * Permission scopes for the key.
1836
- * @default ["read", "write"]
1906
+ * Permission scopes for the key (known values: read, write, admin, "*").
1907
+ * @default ["*"] — the backend default grants the full wildcard; tightening
1908
+ * the default is a separate backend security follow-up.
1837
1909
  */
1838
- scopes?: ApiKeyScope[];
1910
+ scopes?: string[];
1839
1911
  /**
1840
1912
  * Number of days until the key expires.
1841
1913
  * Omit for a key that never expires.
1842
1914
  * @minimum 1
1843
1915
  * @maximum 365
1844
1916
  */
1845
- expires_days?: number;
1917
+ expires_in_days?: number;
1846
1918
  }
1847
1919
  /**
1848
1920
  * Response from creating a new API key.
@@ -1859,19 +1931,40 @@ interface ApiKeyCreated extends ApiKey {
1859
1931
  /**
1860
1932
  * Usage statistics for a tenant over a specific time period.
1861
1933
  *
1862
- * GET /tenants/me/usage
1934
+ * GET /tenants/me/usage — mirrors backend `UsageStatsResponse` (13 fields).
1935
+ *
1936
+ * v3.0.0 BREAKING: full realignment. The previous 5-field shape declared 3
1937
+ * phantom fields (`tokens_used` / `memories_created` / `conversations_created`)
1938
+ * and missed the latency/success-rate/storage fields the backend actually
1939
+ * emits.
1863
1940
  */
1864
1941
  interface UsageStats {
1942
+ /** Tenant identifier (UUID) */
1943
+ tenant_id: string;
1865
1944
  /** Time period for the statistics */
1866
1945
  period: 'day' | 'week' | 'month';
1867
1946
  /** Total API calls in the period */
1868
1947
  api_calls: number;
1869
- /** Total tokens consumed */
1870
- tokens_used?: number;
1871
- /** Number of memories created in the period */
1872
- memories_created?: number;
1873
- /** Number of conversations created in the period */
1874
- conversations_created?: number;
1948
+ /** Success rate over the period (0-100) */
1949
+ success_rate: number;
1950
+ /** Average request latency in milliseconds */
1951
+ avg_latency_ms: number;
1952
+ /** p50 latency in milliseconds (null when no traffic) */
1953
+ p50_latency_ms?: number | null;
1954
+ /** p95 latency in milliseconds (null when no traffic) */
1955
+ p95_latency_ms?: number | null;
1956
+ /** p99 latency in milliseconds (null when no traffic) */
1957
+ p99_latency_ms?: number | null;
1958
+ /** Current number of memories stored */
1959
+ memories_count: number;
1960
+ /** Current number of conversations */
1961
+ conversations_count: number;
1962
+ /** Current number of knowledge graph nodes */
1963
+ graph_nodes_count: number;
1964
+ /** Storage consumed in bytes */
1965
+ storage_used_bytes: number;
1966
+ /** Storage limit in bytes */
1967
+ storage_limit_bytes: number;
1875
1968
  }
1876
1969
 
1877
1970
  /**
@@ -1900,9 +1993,9 @@ interface UsageStats {
1900
1993
  * const tenant = await nexus.tenants.me();
1901
1994
  * console.log(`Tenant: ${tenant.name} (${tenant.tier})`);
1902
1995
  *
1903
- * // Check resource usage
1904
- * const usage = await nexus.tenants.usage();
1905
- * console.log(`Memories: ${usage.memories_count}`);
1996
+ * // Check usage statistics for the last week
1997
+ * const usage = await nexus.tenants.usage('week');
1998
+ * console.log(`API calls: ${usage.api_calls} (${usage.success_rate}% ok)`);
1906
1999
  * ```
1907
2000
  */
1908
2001
  declare class TenantService extends BaseService {
@@ -1916,14 +2009,17 @@ declare class TenantService extends BaseService {
1916
2009
  */
1917
2010
  me(options?: RequestOptions): Promise<Tenant>;
1918
2011
  /**
1919
- * Retrieve the current tenant's resource usage statistics.
2012
+ * Retrieve the current tenant's usage statistics.
1920
2013
  *
1921
- * Returns counts for memories, conversations, and today's API calls.
1922
- * Useful for monitoring quota consumption and building dashboards.
2014
+ * Returns API-call counts, success rate, latency percentiles, resource
2015
+ * counts, and storage usage for the requested period the backend
2016
+ * `UsageStatsResponse` shape (v3.0.0: previously mistyped as a 3-field
2017
+ * `TenantUsage` that never matched the wire).
1923
2018
  *
1924
- * @returns Current resource usage for the authenticated tenant.
2019
+ * @param period - Statistics window: `'day'` (default) | `'week'` | `'month'`.
2020
+ * @returns Usage statistics for the authenticated tenant.
1925
2021
  */
1926
- usage(options?: RequestOptions): Promise<TenantUsage>;
2022
+ usage(period?: 'day' | 'week' | 'month', options?: RequestOptions): Promise<UsageStats>;
1927
2023
  /**
1928
2024
  * List all API keys for the current tenant.
1929
2025
  *
@@ -2504,22 +2600,6 @@ declare const messageCreateSchema: z.ZodObject<{
2504
2600
  metadata?: Record<string, unknown> | undefined;
2505
2601
  }>;
2506
2602
 
2507
- declare const entityCreateSchema: z.ZodObject<{
2508
- name: z.ZodString;
2509
- entity_type: z.ZodString;
2510
- description: z.ZodOptional<z.ZodString>;
2511
- properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2512
- }, "strip", z.ZodTypeAny, {
2513
- name: string;
2514
- entity_type: string;
2515
- description?: string | undefined;
2516
- properties?: Record<string, unknown> | undefined;
2517
- }, {
2518
- name: string;
2519
- entity_type: string;
2520
- description?: string | undefined;
2521
- properties?: Record<string, unknown> | undefined;
2522
- }>;
2523
2603
  declare const graphQueryRequestSchema: z.ZodObject<{
2524
2604
  entity_name: z.ZodString;
2525
2605
  depth: z.ZodOptional<z.ZodNumber>;
@@ -2549,16 +2629,16 @@ declare const extractionRequestSchema: z.ZodObject<{
2549
2629
 
2550
2630
  declare const apiKeyCreateSchema: z.ZodObject<{
2551
2631
  name: z.ZodString;
2552
- scopes: z.ZodOptional<z.ZodArray<z.ZodEnum<["read", "write", "admin"]>, "many">>;
2553
- expires_days: z.ZodOptional<z.ZodNumber>;
2632
+ scopes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2633
+ expires_in_days: z.ZodOptional<z.ZodNumber>;
2554
2634
  }, "strip", z.ZodTypeAny, {
2555
2635
  name: string;
2556
- scopes?: ("read" | "write" | "admin")[] | undefined;
2557
- expires_days?: number | undefined;
2636
+ scopes?: string[] | undefined;
2637
+ expires_in_days?: number | undefined;
2558
2638
  }, {
2559
2639
  name: string;
2560
- scopes?: ("read" | "write" | "admin")[] | undefined;
2561
- expires_days?: number | undefined;
2640
+ scopes?: string[] | undefined;
2641
+ expires_in_days?: number | undefined;
2562
2642
  }>;
2563
2643
 
2564
- export { type Activity, type ActivityProcessingStatus, ActivityService, type ActivityStats, type ActivityStatusResponse, type ActivityStreamRequest, type ActivityStreamResponse, type ActivityType, ApiError, type ApiErrorDetail, type ApiKey, type ApiKeyCreate, type ApiKeyCreated, type ApiKeyScope, type ApiResponse, AuthenticationError, type CacheConfig, type CompoundId, ConfigurationError, type ContextDepth, type ContextDepthPreset, type ContextGraphEntity, type ContextLayer, type ContextRequest, type ContextRetrieveResponse, ContextService, type Conversation, type ConversationCreate, type ConversationDetail, type ConversationList, type ConversationListParams, type ConversationMessage, ConversationService, type ConversationStatus, type ConversationSummary, DEFAULT_CONFIG, DEPTH_PRESETS, type EntityCreate, type EntityListParams, type EntityListResponse, type ErrorReportRequest, type ErrorReportResponse, ErrorService, type ErrorSeverity, type ErrorType, type ExtractionRequest, type ExtractionResult, type FeedbackItemRequest, type FeedbackListItem, type FeedbackListParams, type FeedbackListResponse, type FeedbackResponse, FeedbackService, type FeedbackSubmitRequest, type GraphPath, type GraphPathEntity, type GraphPathRelationship, type GraphQueryRequest, type GraphQueryResponse, type HealthResponse, type HealthStatus, InputValidationError, type JournalEntry, type JournalResponse, type KnowledgeEntity, type KnowledgeRelationship, KnowledgeService, type Memory, type MemoryCreate, type MemoryJournalParams, type MemoryList, type MemoryListParams, type MemorySearch, type MemorySearchResult, MemoryService, type MemoryType, type MemoryUpdate, type Message, type MessageCreate, type MessageList, type MessageListParams, type MessageRole, NetworkError, NexusClient, type NexusConfig, NexusError, NotFoundError, type OfflineConfig, OfflineQueue, type PaginatedResponse, type Pagination, type ProfileMemory, type QueuedRequest, RateLimitError, type RequestOptions, type ResolvedCacheConfig, type ResolvedConfig, type ResolvedRetryConfig, type RetryConfig, type SearchResult, type ServiceStatus, type SortOrder, type Tenant, type TenantQuotas, TenantService, type TenantTier, type TenantUsage, TimeoutError, type UsageStats, ValidationError, apiKeyCreateSchema, contextRequestSchema, conversationCreateSchema, entityCreateSchema, extractionRequestSchema, graphQueryRequestSchema, memoryCreateSchema, memorySearchSchema, memoryUpdateSchema, messageCreateSchema, resolveConfig };
2644
+ export { type Activity, type ActivityProcessingStatus, ActivityService, type ActivityStats, type ActivityStatusResponse, type ActivityStreamRequest, type ActivityStreamResponse, type ActivityType, ApiError, type ApiErrorDetail, type ApiKey, type ApiKeyCreate, type ApiKeyCreated, type ApiResponse, AuthenticationError, type CacheConfig, type CompoundId, ConfigurationError, type ContextDepth, type ContextDepthPreset, type ContextGraphEntity, type ContextLayer, type ContextRequest, type ContextRetrieveResponse, ContextService, type Conversation, type ConversationCreate, type ConversationList, type ConversationListParams, type ConversationMessage, ConversationService, type ConversationStatus, type ConversationSummary, DEFAULT_CONFIG, DEPTH_PRESETS, type EntityListParams, type EntityListResponse, type ErrorReportRequest, type ErrorReportResponse, ErrorService, type ErrorSeverity, type ErrorType, type ExtractionRequest, type ExtractionResult, type FeedbackItemRequest, type FeedbackListItem, type FeedbackListParams, type FeedbackListResponse, type FeedbackResponse, FeedbackService, type FeedbackSubmitRequest, type GraphPath, type GraphPathEntity, type GraphPathRelationship, type GraphQueryRequest, type GraphQueryResponse, type HealthResponse, type HealthStatus, InputValidationError, type JournalEntry, type JournalResponse, type KnowledgeEntity, type KnowledgeRelationship, KnowledgeService, type Memory, type MemoryCreate, type MemoryJournalParams, type MemoryList, type MemoryListParams, type MemorySearch, type MemorySearchResult, MemoryService, type MemoryType, type MemoryUpdate, type Message, type MessageCreate, type MessageList, type MessageListParams, type MessageRole, NetworkError, NexusClient, type NexusConfig, NexusError, NotFoundError, type OfflineConfig, OfflineQueue, type PaginatedResponse, type Pagination, type ProfileMemory, type QueuedRequest, RateLimitError, type RequestOptions, type ResolvedCacheConfig, type ResolvedConfig, type ResolvedRetryConfig, type RetryConfig, type SearchResult, type ServiceStatus, type SortOrder, type Tenant, type TenantQuotas, TenantService, type TenantTier, TimeoutError, type UsageStats, ValidationError, apiKeyCreateSchema, contextRequestSchema, conversationCreateSchema, extractionRequestSchema, graphQueryRequestSchema, memoryCreateSchema, memorySearchSchema, memoryUpdateSchema, messageCreateSchema, resolveConfig };