@nexusm/sdk 2.0.0 → 3.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/dist/index.d.mts CHANGED
@@ -1504,26 +1504,15 @@ interface GraphQueryResponse {
1504
1504
  */
1505
1505
 
1506
1506
  /**
1507
- * Request payload for creating a new knowledge entity.
1507
+ * Parameters for listing knowledge entities.
1508
1508
  *
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.
1509
+ * v3.0.0 BREAKING: `user_id` is required — the backend (and OpenAPI) demand
1510
+ * it (`Query(..., min_length=1)`); the previous optional typing let calls
1511
+ * compile that 422'd at runtime.
1523
1512
  */
1524
1513
  interface EntityListParams {
1525
- /** Filter entities by user ID (owner) */
1526
- user_id?: string;
1514
+ /** Entity owner user ID (required by the backend) */
1515
+ user_id: string;
1527
1516
  /** Filter by entity type classification */
1528
1517
  entity_type?: string;
1529
1518
  /** Maximum number of results to return */
@@ -1534,9 +1523,11 @@ interface EntityListParams {
1534
1523
  /**
1535
1524
  * Service for managing the knowledge graph via Fast GraphRAG.
1536
1525
  *
1537
- * Provides entity CRUD, BFS graph traversal queries, and automatic
1526
+ * Provides entity listing, BFS graph traversal queries, and automatic
1538
1527
  * entity/relationship extraction from unstructured text. Supports
1539
1528
  * both public (agent-owned) and private (user-owned) knowledge.
1529
+ * (v3.0.0: entity creation was removed — the backend has no
1530
+ * POST /knowledge/entities route; entities are created via extract().)
1540
1531
  *
1541
1532
  * @example
1542
1533
  * ```typescript
@@ -1559,19 +1550,12 @@ interface EntityListParams {
1559
1550
  */
1560
1551
  declare class KnowledgeService extends BaseService {
1561
1552
  /**
1562
- * Create a new knowledge entity in the graph.
1553
+ * List knowledge entities for a user with optional filtering.
1563
1554
  *
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.
1555
+ * @param params - Filters: required user_id (backend-enforced), optional entity_type and pagination controls.
1572
1556
  * @returns Paginated list of knowledge entities.
1573
1557
  */
1574
- listEntities(params?: EntityListParams, options?: RequestOptions): Promise<EntityListResponse>;
1558
+ listEntities(params: EntityListParams, options?: RequestOptions): Promise<EntityListResponse>;
1575
1559
  /**
1576
1560
  * Query the knowledge graph using BFS traversal.
1577
1561
  *
@@ -1753,14 +1737,21 @@ declare class ActivityService extends BaseService {
1753
1737
  * Supports multi-tenant isolation, API key management,
1754
1738
  * quota tracking, and usage statistics.
1755
1739
  *
1756
- * Based on Nexus API v2.0 OpenAPI specification.
1740
+ * v3.0.0 BREAKING (tenant-contract-reconciliation, 2026-06-10): canonical =
1741
+ * backend Pydantic response models (`schemas/tenant.py`). The previous shapes
1742
+ * were drifted: `Tenant` had a phantom nested `usage` object (the wire is
1743
+ * flat), `UsageStats` declared 3 phantom fields and missed 11 real ones, and
1744
+ * `ApiKeyCreate` used the phantom request field `expires_days` (the wire is
1745
+ * `expires_in_days` — the old name was silently dropped by the backend,
1746
+ * creating never-expiring keys).
1757
1747
  */
1758
1748
  /** Available tenant subscription tiers */
1759
1749
  type TenantTier = 'free' | 'starter' | 'pro' | 'enterprise';
1760
- /** API Key permission scopes */
1761
- type ApiKeyScope = 'read' | 'write' | 'admin';
1762
1750
  /**
1763
1751
  * Tenant quotas configuration defining resource limits.
1752
+ *
1753
+ * The backend serializes a free-form object; the keys below are the
1754
+ * well-known ones. Unknown keys are preserved via the index signature.
1764
1755
  */
1765
1756
  interface TenantQuotas {
1766
1757
  /** Maximum number of memories allowed */
@@ -1769,23 +1760,18 @@ interface TenantQuotas {
1769
1760
  max_conversations?: number;
1770
1761
  /** Maximum API calls per day */
1771
1762
  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;
1763
+ /** Forward-compatible: any additional quota dimensions */
1764
+ [key: string]: unknown;
1783
1765
  }
1784
1766
  /**
1785
1767
  * A tenant (organization) on the Nexus platform.
1786
1768
  * Each tenant has isolated data and configurable quotas.
1787
1769
  *
1788
- * GET /tenants/me
1770
+ * GET /tenants/me — mirrors backend `TenantInfoResponse` (flat shape).
1771
+ *
1772
+ * v3.0.0 BREAKING: usage counts are FLAT top-level fields (the nested
1773
+ * `usage` object never existed on the wire); adds `quota_remaining` and
1774
+ * `graph_nodes_count` (previously missing).
1789
1775
  */
1790
1776
  interface Tenant {
1791
1777
  /** Unique tenant identifier (UUID) */
@@ -1795,17 +1781,28 @@ interface Tenant {
1795
1781
  /** Subscription tier */
1796
1782
  tier: TenantTier;
1797
1783
  /** Resource quotas */
1798
- quotas?: TenantQuotas;
1799
- /** Current resource usage */
1800
- usage?: TenantUsage;
1784
+ quotas: TenantQuotas;
1785
+ /** Remaining headroom per quota dimension */
1786
+ quota_remaining: Record<string, number>;
1801
1787
  /** Timestamp when the tenant was created (ISO 8601) */
1802
1788
  created_at: string;
1789
+ /** Current number of memories stored (flat — not nested under `usage`) */
1790
+ memories_count: number;
1791
+ /** Current number of conversations (flat — not nested under `usage`) */
1792
+ conversations_count: number;
1793
+ /** Current number of knowledge graph nodes */
1794
+ graph_nodes_count: number;
1803
1795
  }
1804
1796
  /**
1805
1797
  * An API key for authenticating with the Nexus platform.
1806
1798
  * The full key value is only returned once at creation time.
1807
1799
  *
1808
1800
  * GET /tenants/me/api-keys
1801
+ *
1802
+ * v3.0.0: `scopes` is a free-form string array documenting backend reality —
1803
+ * known values are `"read"`, `"write"`, `"admin"` and the `"*"` wildcard
1804
+ * (the backend authorizes via `scope in scopes or "*" in scopes`). The old
1805
+ * `ApiKeyScope` enum could not represent `"*"`, the actual default.
1809
1806
  */
1810
1807
  interface ApiKey {
1811
1808
  /** Unique API key identifier (UUID) */
@@ -1814,8 +1811,8 @@ interface ApiKey {
1814
1811
  key_prefix: string;
1815
1812
  /** Human-readable name for the API key */
1816
1813
  name: string;
1817
- /** Permission scopes granted to this key */
1818
- scopes: ApiKeyScope[];
1814
+ /** Permission scopes granted to this key (known values: read, write, admin, "*") */
1815
+ scopes: string[];
1819
1816
  /** Expiration timestamp (null = never expires) (ISO 8601) */
1820
1817
  expires_at?: string | null;
1821
1818
  /** Last time this key was used (ISO 8601) */
@@ -1826,23 +1823,28 @@ interface ApiKey {
1826
1823
  /**
1827
1824
  * Request payload for creating a new API key.
1828
1825
  *
1829
- * POST /tenants/me/api-keys
1826
+ * POST /tenants/me/api-keys — mirrors backend `ApiKeyCreate`.
1827
+ *
1828
+ * v3.0.0 BREAKING: `expires_days` → `expires_in_days` (the backend request
1829
+ * field). The old name was silently ignored by the backend (no
1830
+ * `extra=forbid`), so keys created through the SDK never expired.
1830
1831
  */
1831
1832
  interface ApiKeyCreate {
1832
- /** Human-readable name for the API key (1-100 characters) */
1833
+ /** Human-readable name for the API key (1-255 characters) */
1833
1834
  name: string;
1834
1835
  /**
1835
- * Permission scopes for the key.
1836
- * @default ["read", "write"]
1836
+ * Permission scopes for the key (known values: read, write, admin, "*").
1837
+ * @default ["*"] — the backend default grants the full wildcard; tightening
1838
+ * the default is a separate backend security follow-up.
1837
1839
  */
1838
- scopes?: ApiKeyScope[];
1840
+ scopes?: string[];
1839
1841
  /**
1840
1842
  * Number of days until the key expires.
1841
1843
  * Omit for a key that never expires.
1842
1844
  * @minimum 1
1843
1845
  * @maximum 365
1844
1846
  */
1845
- expires_days?: number;
1847
+ expires_in_days?: number;
1846
1848
  }
1847
1849
  /**
1848
1850
  * Response from creating a new API key.
@@ -1859,19 +1861,40 @@ interface ApiKeyCreated extends ApiKey {
1859
1861
  /**
1860
1862
  * Usage statistics for a tenant over a specific time period.
1861
1863
  *
1862
- * GET /tenants/me/usage
1864
+ * GET /tenants/me/usage — mirrors backend `UsageStatsResponse` (13 fields).
1865
+ *
1866
+ * v3.0.0 BREAKING: full realignment. The previous 5-field shape declared 3
1867
+ * phantom fields (`tokens_used` / `memories_created` / `conversations_created`)
1868
+ * and missed the latency/success-rate/storage fields the backend actually
1869
+ * emits.
1863
1870
  */
1864
1871
  interface UsageStats {
1872
+ /** Tenant identifier (UUID) */
1873
+ tenant_id: string;
1865
1874
  /** Time period for the statistics */
1866
1875
  period: 'day' | 'week' | 'month';
1867
1876
  /** Total API calls in the period */
1868
1877
  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;
1878
+ /** Success rate over the period (0-100) */
1879
+ success_rate: number;
1880
+ /** Average request latency in milliseconds */
1881
+ avg_latency_ms: number;
1882
+ /** p50 latency in milliseconds (null when no traffic) */
1883
+ p50_latency_ms?: number | null;
1884
+ /** p95 latency in milliseconds (null when no traffic) */
1885
+ p95_latency_ms?: number | null;
1886
+ /** p99 latency in milliseconds (null when no traffic) */
1887
+ p99_latency_ms?: number | null;
1888
+ /** Current number of memories stored */
1889
+ memories_count: number;
1890
+ /** Current number of conversations */
1891
+ conversations_count: number;
1892
+ /** Current number of knowledge graph nodes */
1893
+ graph_nodes_count: number;
1894
+ /** Storage consumed in bytes */
1895
+ storage_used_bytes: number;
1896
+ /** Storage limit in bytes */
1897
+ storage_limit_bytes: number;
1875
1898
  }
1876
1899
 
1877
1900
  /**
@@ -1900,9 +1923,9 @@ interface UsageStats {
1900
1923
  * const tenant = await nexus.tenants.me();
1901
1924
  * console.log(`Tenant: ${tenant.name} (${tenant.tier})`);
1902
1925
  *
1903
- * // Check resource usage
1904
- * const usage = await nexus.tenants.usage();
1905
- * console.log(`Memories: ${usage.memories_count}`);
1926
+ * // Check usage statistics for the last week
1927
+ * const usage = await nexus.tenants.usage('week');
1928
+ * console.log(`API calls: ${usage.api_calls} (${usage.success_rate}% ok)`);
1906
1929
  * ```
1907
1930
  */
1908
1931
  declare class TenantService extends BaseService {
@@ -1916,14 +1939,17 @@ declare class TenantService extends BaseService {
1916
1939
  */
1917
1940
  me(options?: RequestOptions): Promise<Tenant>;
1918
1941
  /**
1919
- * Retrieve the current tenant's resource usage statistics.
1942
+ * Retrieve the current tenant's usage statistics.
1920
1943
  *
1921
- * Returns counts for memories, conversations, and today's API calls.
1922
- * Useful for monitoring quota consumption and building dashboards.
1944
+ * Returns API-call counts, success rate, latency percentiles, resource
1945
+ * counts, and storage usage for the requested period the backend
1946
+ * `UsageStatsResponse` shape (v3.0.0: previously mistyped as a 3-field
1947
+ * `TenantUsage` that never matched the wire).
1923
1948
  *
1924
- * @returns Current resource usage for the authenticated tenant.
1949
+ * @param period - Statistics window: `'day'` (default) | `'week'` | `'month'`.
1950
+ * @returns Usage statistics for the authenticated tenant.
1925
1951
  */
1926
- usage(options?: RequestOptions): Promise<TenantUsage>;
1952
+ usage(period?: 'day' | 'week' | 'month', options?: RequestOptions): Promise<UsageStats>;
1927
1953
  /**
1928
1954
  * List all API keys for the current tenant.
1929
1955
  *
@@ -2504,22 +2530,6 @@ declare const messageCreateSchema: z.ZodObject<{
2504
2530
  metadata?: Record<string, unknown> | undefined;
2505
2531
  }>;
2506
2532
 
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
2533
  declare const graphQueryRequestSchema: z.ZodObject<{
2524
2534
  entity_name: z.ZodString;
2525
2535
  depth: z.ZodOptional<z.ZodNumber>;
@@ -2549,16 +2559,16 @@ declare const extractionRequestSchema: z.ZodObject<{
2549
2559
 
2550
2560
  declare const apiKeyCreateSchema: z.ZodObject<{
2551
2561
  name: z.ZodString;
2552
- scopes: z.ZodOptional<z.ZodArray<z.ZodEnum<["read", "write", "admin"]>, "many">>;
2553
- expires_days: z.ZodOptional<z.ZodNumber>;
2562
+ scopes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2563
+ expires_in_days: z.ZodOptional<z.ZodNumber>;
2554
2564
  }, "strip", z.ZodTypeAny, {
2555
2565
  name: string;
2556
- scopes?: ("read" | "write" | "admin")[] | undefined;
2557
- expires_days?: number | undefined;
2566
+ scopes?: string[] | undefined;
2567
+ expires_in_days?: number | undefined;
2558
2568
  }, {
2559
2569
  name: string;
2560
- scopes?: ("read" | "write" | "admin")[] | undefined;
2561
- expires_days?: number | undefined;
2570
+ scopes?: string[] | undefined;
2571
+ expires_in_days?: number | undefined;
2562
2572
  }>;
2563
2573
 
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 };
2574
+ 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 ConversationDetail, 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 };