@dakera-ai/dakera 0.5.0 → 0.6.1

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
@@ -275,7 +275,7 @@ interface TextUpsertResponse {
275
275
  /** Approximate number of tokens processed */
276
276
  tokens_processed: number;
277
277
  /** Embedding model used */
278
- model: string;
278
+ model: EmbeddingModel;
279
279
  /** Time spent generating embeddings in milliseconds */
280
280
  embedding_time_ms: number;
281
281
  }
@@ -316,7 +316,7 @@ interface TextQueryResponse {
316
316
  /** Search results */
317
317
  results: TextSearchResult[];
318
318
  /** Embedding model used */
319
- model: string;
319
+ model: EmbeddingModel;
320
320
  /** Time spent generating query embedding in milliseconds */
321
321
  embedding_time_ms: number;
322
322
  /** Time spent searching in milliseconds */
@@ -342,12 +342,37 @@ interface BatchTextQueryResponse {
342
342
  /** Results for each query */
343
343
  results: TextSearchResult[][];
344
344
  /** Embedding model used */
345
- model: string;
345
+ model: EmbeddingModel;
346
346
  /** Time spent generating all embeddings in milliseconds */
347
347
  embedding_time_ms: number;
348
348
  /** Time spent on all searches in milliseconds */
349
349
  search_time_ms: number;
350
350
  }
351
+ /**
352
+ * Request body for ``PUT /v1/namespaces/:namespace`` (upsert semantics).
353
+ *
354
+ * Creates the namespace if it does not exist, or updates its configuration
355
+ * if it already exists.
356
+ */
357
+ interface ConfigureNamespaceRequest {
358
+ /** Vector dimension. Required on creation; must match on update. */
359
+ dimension: number;
360
+ /** Distance metric (default: cosine). */
361
+ distance?: DistanceMetric;
362
+ }
363
+ /**
364
+ * Response from ``PUT /v1/namespaces/:namespace``.
365
+ */
366
+ interface ConfigureNamespaceResponse {
367
+ /** Namespace name. */
368
+ namespace: string;
369
+ /** Vector dimension. */
370
+ dimension: number;
371
+ /** Distance metric in use. */
372
+ distance: DistanceMetric;
373
+ /** ``true`` if the namespace was newly created; ``false`` if it already existed. */
374
+ created: boolean;
375
+ }
351
376
  /** Memory type classification */
352
377
  type MemoryType = 'episodic' | 'semantic' | 'procedural' | 'strategic';
353
378
  /** Request to store a memory */
@@ -1210,6 +1235,17 @@ declare class DakeraClient {
1210
1235
  indexType?: string;
1211
1236
  metadata?: Record<string, unknown>;
1212
1237
  }): Promise<NamespaceInfo>;
1238
+ /**
1239
+ * Create or update a namespace configuration (upsert semantics).
1240
+ *
1241
+ * Creates the namespace if it does not exist, or updates its configuration
1242
+ * if it already exists. Requires Write scope.
1243
+ *
1244
+ * @param namespace - Namespace name
1245
+ * @param request - dimension and optional distance metric
1246
+ * @returns ConfigureNamespaceResponse with ``created: true`` if newly created
1247
+ */
1248
+ configureNamespace(namespace: string, request: ConfigureNamespaceRequest): Promise<ConfigureNamespaceResponse>;
1213
1249
  /**
1214
1250
  * Delete a namespace.
1215
1251
  *
@@ -1727,11 +1763,30 @@ declare class DakeraClient {
1727
1763
  /**
1728
1764
  * Dakera SDK Errors
1729
1765
  */
1766
+ /** Server error codes returned in structured error responses */
1767
+ declare enum ErrorCode {
1768
+ NAMESPACE_NOT_FOUND = "NAMESPACE_NOT_FOUND",
1769
+ VECTOR_NOT_FOUND = "VECTOR_NOT_FOUND",
1770
+ DIMENSION_MISMATCH = "DIMENSION_MISMATCH",
1771
+ EMPTY_VECTOR = "EMPTY_VECTOR",
1772
+ INVALID_REQUEST = "INVALID_REQUEST",
1773
+ STORAGE_ERROR = "STORAGE_ERROR",
1774
+ INTERNAL_ERROR = "INTERNAL_ERROR",
1775
+ QUOTA_EXCEEDED = "QUOTA_EXCEEDED",
1776
+ SERVICE_UNAVAILABLE = "SERVICE_UNAVAILABLE",
1777
+ AUTHENTICATION_REQUIRED = "AUTHENTICATION_REQUIRED",
1778
+ INVALID_API_KEY = "INVALID_API_KEY",
1779
+ API_KEY_EXPIRED = "API_KEY_EXPIRED",
1780
+ INSUFFICIENT_SCOPE = "INSUFFICIENT_SCOPE",
1781
+ NAMESPACE_ACCESS_DENIED = "NAMESPACE_ACCESS_DENIED",
1782
+ UNKNOWN = "UNKNOWN"
1783
+ }
1730
1784
  /** Base error class for all Dakera errors */
1731
1785
  declare class DakeraError extends Error {
1732
1786
  readonly statusCode?: number;
1733
1787
  readonly responseBody?: unknown;
1734
- constructor(message: string, statusCode?: number, responseBody?: unknown);
1788
+ readonly code?: ErrorCode;
1789
+ constructor(message: string, statusCode?: number, responseBody?: unknown, code?: ErrorCode);
1735
1790
  }
1736
1791
  /** Raised when unable to connect to Dakera server */
1737
1792
  declare class ConnectionError extends DakeraError {
@@ -1739,28 +1794,32 @@ declare class ConnectionError extends DakeraError {
1739
1794
  }
1740
1795
  /** Raised when a requested resource is not found */
1741
1796
  declare class NotFoundError extends DakeraError {
1742
- constructor(message: string, statusCode?: number, responseBody?: unknown);
1797
+ constructor(message: string, statusCode?: number, responseBody?: unknown, code?: ErrorCode);
1743
1798
  }
1744
1799
  /** Raised when request validation fails */
1745
1800
  declare class ValidationError extends DakeraError {
1746
- constructor(message: string, statusCode?: number, responseBody?: unknown);
1801
+ constructor(message: string, statusCode?: number, responseBody?: unknown, code?: ErrorCode);
1747
1802
  }
1748
1803
  /** Raised when rate limit is exceeded */
1749
1804
  declare class RateLimitError extends DakeraError {
1750
1805
  readonly retryAfter?: number;
1751
- constructor(message: string, statusCode?: number, responseBody?: unknown, retryAfter?: number);
1806
+ constructor(message: string, statusCode?: number, responseBody?: unknown, retryAfter?: number, code?: ErrorCode);
1752
1807
  }
1753
1808
  /** Raised when the server returns a 5xx error */
1754
1809
  declare class ServerError extends DakeraError {
1755
- constructor(message: string, statusCode?: number, responseBody?: unknown);
1810
+ constructor(message: string, statusCode?: number, responseBody?: unknown, code?: ErrorCode);
1756
1811
  }
1757
1812
  /** Raised when authentication fails */
1758
1813
  declare class AuthenticationError extends DakeraError {
1759
- constructor(message: string, statusCode?: number, responseBody?: unknown);
1814
+ constructor(message: string, statusCode?: number, responseBody?: unknown, code?: ErrorCode);
1815
+ }
1816
+ /** Raised when authorization fails (403 Forbidden) */
1817
+ declare class AuthorizationError extends DakeraError {
1818
+ constructor(message: string, statusCode?: number, responseBody?: unknown, code?: ErrorCode);
1760
1819
  }
1761
1820
  /** Raised when a request times out */
1762
1821
  declare class TimeoutError extends DakeraError {
1763
1822
  constructor(message: string);
1764
1823
  }
1765
1824
 
1766
- export { type AccessPatternHint, type AgentId, type AgentNetworkEdge, type AgentNetworkInfo, type AgentNetworkNode, type AgentNetworkStats, type AgentStats, type AgentSummary, type AggregationGroup, type AggregationRequest, type AggregationResponse, type AnalyticsOptions, type AnalyticsOverview, type ApiKey, AuthenticationError, type BackupInfo, type BatchQuerySpec, type BatchTextQueryOptions, type BatchTextQueryResponse, type Branded, type CacheStats, type ClientOptions, type ClusterNode, type ClusterStatus, type ColumnUpsertRequest, ConnectionError, type ConsolidateRequest, type ConsolidateResponse, type CreateKeyRequest, type CrossAgentNetworkRequest, type CrossAgentNetworkResponse, DakeraClient, DakeraError, type DakeraEvent, type DeduplicateRequest, type DeduplicateResponse, type DeleteOptions, type DeleteResponse, type DistanceMetric, type Document, type DocumentInput, type EmbeddingModel, type ExportRequest, type ExportResponse, type ExportedVector, type FilterExpression, type FilterOperators, type FullKnowledgeGraphRequest, type FullTextSearchResult, type HealthResponse, type HybridSearchResult, type IndexStats, type JobProgressEvent, type KeyUsage, type KnowledgeEdge, type KnowledgeGraphRequest, type KnowledgeGraphResponse, type KnowledgeNode, type LatencyAnalytics, type ListSessionsOptions, type Memory, type MemoryEvent, type MemoryFeedbackRequest, type MemoryFeedbackResponse, type MemoryId, type MemoryType, type MultiVectorSearchRequest, type MultiVectorSearchResponse, type MultiVectorSearchResult, type NamespaceCreatedEvent, type NamespaceDeletedEvent, type NamespaceInfo, NotFoundError, type OpStatus, type OperationProgressEvent, type QueryExplainRequest, type QueryExplainResponse, type QueryOptions, type QueryResult, RateLimitError, type ReadConsistency, type RecallRequest, type RecalledMemory, type SearchResult, ServerError, type Session, type SessionId, type SlowQuery, type StalenessConfig, type StartSessionRequest, type StorageAnalytics, type StoreMemoryRequest, type StoreMemoryResponse, type StreamLaggedEvent, type SummarizeRequest, type SummarizeResponse, type TextDocument, type TextQueryOptions, type TextQueryResponse, type TextSearchResult, type TextUpsertOptions, type TextUpsertResponse, type ThroughputAnalytics, TimeoutError, type TtlConfig, type UnifiedQueryRequest, type UnifiedQueryResponse, type UnifiedSearchResult, type UpdateImportanceRequest, type UpdateMemoryRequest, type UpsertOptions, type UpsertResponse, ValidationError, type Vector, type VectorId, type VectorInput, type VectorMutationOp, type VectorsMutatedEvent, type WarmCacheRequest, type WarmCacheResponse, type WarmingPriority, type WarmingTargetTier, agentId, memoryId, sessionId, vectorId };
1825
+ export { type AccessPatternHint, type AgentId, type AgentNetworkEdge, type AgentNetworkInfo, type AgentNetworkNode, type AgentNetworkStats, type AgentStats, type AgentSummary, type AggregationGroup, type AggregationRequest, type AggregationResponse, type AnalyticsOptions, type AnalyticsOverview, type ApiKey, AuthenticationError, AuthorizationError, type BackupInfo, type BatchQuerySpec, type BatchTextQueryOptions, type BatchTextQueryResponse, type Branded, type CacheStats, type ClientOptions, type ClusterNode, type ClusterStatus, type ColumnUpsertRequest, type ConfigureNamespaceRequest, type ConfigureNamespaceResponse, ConnectionError, type ConsolidateRequest, type ConsolidateResponse, type CreateKeyRequest, type CrossAgentNetworkRequest, type CrossAgentNetworkResponse, DakeraClient, DakeraError, type DakeraEvent, type DeduplicateRequest, type DeduplicateResponse, type DeleteOptions, type DeleteResponse, type DistanceMetric, type Document, type DocumentInput, type EmbeddingModel, ErrorCode, type ExportRequest, type ExportResponse, type ExportedVector, type FilterExpression, type FilterOperators, type FullKnowledgeGraphRequest, type FullTextSearchResult, type HealthResponse, type HybridSearchResult, type IndexStats, type JobProgressEvent, type KeyUsage, type KnowledgeEdge, type KnowledgeGraphRequest, type KnowledgeGraphResponse, type KnowledgeNode, type LatencyAnalytics, type ListSessionsOptions, type Memory, type MemoryEvent, type MemoryFeedbackRequest, type MemoryFeedbackResponse, type MemoryId, type MemoryType, type MultiVectorSearchRequest, type MultiVectorSearchResponse, type MultiVectorSearchResult, type NamespaceCreatedEvent, type NamespaceDeletedEvent, type NamespaceInfo, NotFoundError, type OpStatus, type OperationProgressEvent, type QueryExplainRequest, type QueryExplainResponse, type QueryOptions, type QueryResult, RateLimitError, type ReadConsistency, type RecallRequest, type RecalledMemory, type SearchResult, ServerError, type Session, type SessionId, type SlowQuery, type StalenessConfig, type StartSessionRequest, type StorageAnalytics, type StoreMemoryRequest, type StoreMemoryResponse, type StreamLaggedEvent, type SummarizeRequest, type SummarizeResponse, type TextDocument, type TextQueryOptions, type TextQueryResponse, type TextSearchResult, type TextUpsertOptions, type TextUpsertResponse, type ThroughputAnalytics, TimeoutError, type TtlConfig, type UnifiedQueryRequest, type UnifiedQueryResponse, type UnifiedSearchResult, type UpdateImportanceRequest, type UpdateMemoryRequest, type UpsertOptions, type UpsertResponse, ValidationError, type Vector, type VectorId, type VectorInput, type VectorMutationOp, type VectorsMutatedEvent, type WarmCacheRequest, type WarmCacheResponse, type WarmingPriority, type WarmingTargetTier, agentId, memoryId, sessionId, vectorId };
package/dist/index.d.ts CHANGED
@@ -275,7 +275,7 @@ interface TextUpsertResponse {
275
275
  /** Approximate number of tokens processed */
276
276
  tokens_processed: number;
277
277
  /** Embedding model used */
278
- model: string;
278
+ model: EmbeddingModel;
279
279
  /** Time spent generating embeddings in milliseconds */
280
280
  embedding_time_ms: number;
281
281
  }
@@ -316,7 +316,7 @@ interface TextQueryResponse {
316
316
  /** Search results */
317
317
  results: TextSearchResult[];
318
318
  /** Embedding model used */
319
- model: string;
319
+ model: EmbeddingModel;
320
320
  /** Time spent generating query embedding in milliseconds */
321
321
  embedding_time_ms: number;
322
322
  /** Time spent searching in milliseconds */
@@ -342,12 +342,37 @@ interface BatchTextQueryResponse {
342
342
  /** Results for each query */
343
343
  results: TextSearchResult[][];
344
344
  /** Embedding model used */
345
- model: string;
345
+ model: EmbeddingModel;
346
346
  /** Time spent generating all embeddings in milliseconds */
347
347
  embedding_time_ms: number;
348
348
  /** Time spent on all searches in milliseconds */
349
349
  search_time_ms: number;
350
350
  }
351
+ /**
352
+ * Request body for ``PUT /v1/namespaces/:namespace`` (upsert semantics).
353
+ *
354
+ * Creates the namespace if it does not exist, or updates its configuration
355
+ * if it already exists.
356
+ */
357
+ interface ConfigureNamespaceRequest {
358
+ /** Vector dimension. Required on creation; must match on update. */
359
+ dimension: number;
360
+ /** Distance metric (default: cosine). */
361
+ distance?: DistanceMetric;
362
+ }
363
+ /**
364
+ * Response from ``PUT /v1/namespaces/:namespace``.
365
+ */
366
+ interface ConfigureNamespaceResponse {
367
+ /** Namespace name. */
368
+ namespace: string;
369
+ /** Vector dimension. */
370
+ dimension: number;
371
+ /** Distance metric in use. */
372
+ distance: DistanceMetric;
373
+ /** ``true`` if the namespace was newly created; ``false`` if it already existed. */
374
+ created: boolean;
375
+ }
351
376
  /** Memory type classification */
352
377
  type MemoryType = 'episodic' | 'semantic' | 'procedural' | 'strategic';
353
378
  /** Request to store a memory */
@@ -1210,6 +1235,17 @@ declare class DakeraClient {
1210
1235
  indexType?: string;
1211
1236
  metadata?: Record<string, unknown>;
1212
1237
  }): Promise<NamespaceInfo>;
1238
+ /**
1239
+ * Create or update a namespace configuration (upsert semantics).
1240
+ *
1241
+ * Creates the namespace if it does not exist, or updates its configuration
1242
+ * if it already exists. Requires Write scope.
1243
+ *
1244
+ * @param namespace - Namespace name
1245
+ * @param request - dimension and optional distance metric
1246
+ * @returns ConfigureNamespaceResponse with ``created: true`` if newly created
1247
+ */
1248
+ configureNamespace(namespace: string, request: ConfigureNamespaceRequest): Promise<ConfigureNamespaceResponse>;
1213
1249
  /**
1214
1250
  * Delete a namespace.
1215
1251
  *
@@ -1727,11 +1763,30 @@ declare class DakeraClient {
1727
1763
  /**
1728
1764
  * Dakera SDK Errors
1729
1765
  */
1766
+ /** Server error codes returned in structured error responses */
1767
+ declare enum ErrorCode {
1768
+ NAMESPACE_NOT_FOUND = "NAMESPACE_NOT_FOUND",
1769
+ VECTOR_NOT_FOUND = "VECTOR_NOT_FOUND",
1770
+ DIMENSION_MISMATCH = "DIMENSION_MISMATCH",
1771
+ EMPTY_VECTOR = "EMPTY_VECTOR",
1772
+ INVALID_REQUEST = "INVALID_REQUEST",
1773
+ STORAGE_ERROR = "STORAGE_ERROR",
1774
+ INTERNAL_ERROR = "INTERNAL_ERROR",
1775
+ QUOTA_EXCEEDED = "QUOTA_EXCEEDED",
1776
+ SERVICE_UNAVAILABLE = "SERVICE_UNAVAILABLE",
1777
+ AUTHENTICATION_REQUIRED = "AUTHENTICATION_REQUIRED",
1778
+ INVALID_API_KEY = "INVALID_API_KEY",
1779
+ API_KEY_EXPIRED = "API_KEY_EXPIRED",
1780
+ INSUFFICIENT_SCOPE = "INSUFFICIENT_SCOPE",
1781
+ NAMESPACE_ACCESS_DENIED = "NAMESPACE_ACCESS_DENIED",
1782
+ UNKNOWN = "UNKNOWN"
1783
+ }
1730
1784
  /** Base error class for all Dakera errors */
1731
1785
  declare class DakeraError extends Error {
1732
1786
  readonly statusCode?: number;
1733
1787
  readonly responseBody?: unknown;
1734
- constructor(message: string, statusCode?: number, responseBody?: unknown);
1788
+ readonly code?: ErrorCode;
1789
+ constructor(message: string, statusCode?: number, responseBody?: unknown, code?: ErrorCode);
1735
1790
  }
1736
1791
  /** Raised when unable to connect to Dakera server */
1737
1792
  declare class ConnectionError extends DakeraError {
@@ -1739,28 +1794,32 @@ declare class ConnectionError extends DakeraError {
1739
1794
  }
1740
1795
  /** Raised when a requested resource is not found */
1741
1796
  declare class NotFoundError extends DakeraError {
1742
- constructor(message: string, statusCode?: number, responseBody?: unknown);
1797
+ constructor(message: string, statusCode?: number, responseBody?: unknown, code?: ErrorCode);
1743
1798
  }
1744
1799
  /** Raised when request validation fails */
1745
1800
  declare class ValidationError extends DakeraError {
1746
- constructor(message: string, statusCode?: number, responseBody?: unknown);
1801
+ constructor(message: string, statusCode?: number, responseBody?: unknown, code?: ErrorCode);
1747
1802
  }
1748
1803
  /** Raised when rate limit is exceeded */
1749
1804
  declare class RateLimitError extends DakeraError {
1750
1805
  readonly retryAfter?: number;
1751
- constructor(message: string, statusCode?: number, responseBody?: unknown, retryAfter?: number);
1806
+ constructor(message: string, statusCode?: number, responseBody?: unknown, retryAfter?: number, code?: ErrorCode);
1752
1807
  }
1753
1808
  /** Raised when the server returns a 5xx error */
1754
1809
  declare class ServerError extends DakeraError {
1755
- constructor(message: string, statusCode?: number, responseBody?: unknown);
1810
+ constructor(message: string, statusCode?: number, responseBody?: unknown, code?: ErrorCode);
1756
1811
  }
1757
1812
  /** Raised when authentication fails */
1758
1813
  declare class AuthenticationError extends DakeraError {
1759
- constructor(message: string, statusCode?: number, responseBody?: unknown);
1814
+ constructor(message: string, statusCode?: number, responseBody?: unknown, code?: ErrorCode);
1815
+ }
1816
+ /** Raised when authorization fails (403 Forbidden) */
1817
+ declare class AuthorizationError extends DakeraError {
1818
+ constructor(message: string, statusCode?: number, responseBody?: unknown, code?: ErrorCode);
1760
1819
  }
1761
1820
  /** Raised when a request times out */
1762
1821
  declare class TimeoutError extends DakeraError {
1763
1822
  constructor(message: string);
1764
1823
  }
1765
1824
 
1766
- export { type AccessPatternHint, type AgentId, type AgentNetworkEdge, type AgentNetworkInfo, type AgentNetworkNode, type AgentNetworkStats, type AgentStats, type AgentSummary, type AggregationGroup, type AggregationRequest, type AggregationResponse, type AnalyticsOptions, type AnalyticsOverview, type ApiKey, AuthenticationError, type BackupInfo, type BatchQuerySpec, type BatchTextQueryOptions, type BatchTextQueryResponse, type Branded, type CacheStats, type ClientOptions, type ClusterNode, type ClusterStatus, type ColumnUpsertRequest, ConnectionError, type ConsolidateRequest, type ConsolidateResponse, type CreateKeyRequest, type CrossAgentNetworkRequest, type CrossAgentNetworkResponse, DakeraClient, DakeraError, type DakeraEvent, type DeduplicateRequest, type DeduplicateResponse, type DeleteOptions, type DeleteResponse, type DistanceMetric, type Document, type DocumentInput, type EmbeddingModel, type ExportRequest, type ExportResponse, type ExportedVector, type FilterExpression, type FilterOperators, type FullKnowledgeGraphRequest, type FullTextSearchResult, type HealthResponse, type HybridSearchResult, type IndexStats, type JobProgressEvent, type KeyUsage, type KnowledgeEdge, type KnowledgeGraphRequest, type KnowledgeGraphResponse, type KnowledgeNode, type LatencyAnalytics, type ListSessionsOptions, type Memory, type MemoryEvent, type MemoryFeedbackRequest, type MemoryFeedbackResponse, type MemoryId, type MemoryType, type MultiVectorSearchRequest, type MultiVectorSearchResponse, type MultiVectorSearchResult, type NamespaceCreatedEvent, type NamespaceDeletedEvent, type NamespaceInfo, NotFoundError, type OpStatus, type OperationProgressEvent, type QueryExplainRequest, type QueryExplainResponse, type QueryOptions, type QueryResult, RateLimitError, type ReadConsistency, type RecallRequest, type RecalledMemory, type SearchResult, ServerError, type Session, type SessionId, type SlowQuery, type StalenessConfig, type StartSessionRequest, type StorageAnalytics, type StoreMemoryRequest, type StoreMemoryResponse, type StreamLaggedEvent, type SummarizeRequest, type SummarizeResponse, type TextDocument, type TextQueryOptions, type TextQueryResponse, type TextSearchResult, type TextUpsertOptions, type TextUpsertResponse, type ThroughputAnalytics, TimeoutError, type TtlConfig, type UnifiedQueryRequest, type UnifiedQueryResponse, type UnifiedSearchResult, type UpdateImportanceRequest, type UpdateMemoryRequest, type UpsertOptions, type UpsertResponse, ValidationError, type Vector, type VectorId, type VectorInput, type VectorMutationOp, type VectorsMutatedEvent, type WarmCacheRequest, type WarmCacheResponse, type WarmingPriority, type WarmingTargetTier, agentId, memoryId, sessionId, vectorId };
1825
+ export { type AccessPatternHint, type AgentId, type AgentNetworkEdge, type AgentNetworkInfo, type AgentNetworkNode, type AgentNetworkStats, type AgentStats, type AgentSummary, type AggregationGroup, type AggregationRequest, type AggregationResponse, type AnalyticsOptions, type AnalyticsOverview, type ApiKey, AuthenticationError, AuthorizationError, type BackupInfo, type BatchQuerySpec, type BatchTextQueryOptions, type BatchTextQueryResponse, type Branded, type CacheStats, type ClientOptions, type ClusterNode, type ClusterStatus, type ColumnUpsertRequest, type ConfigureNamespaceRequest, type ConfigureNamespaceResponse, ConnectionError, type ConsolidateRequest, type ConsolidateResponse, type CreateKeyRequest, type CrossAgentNetworkRequest, type CrossAgentNetworkResponse, DakeraClient, DakeraError, type DakeraEvent, type DeduplicateRequest, type DeduplicateResponse, type DeleteOptions, type DeleteResponse, type DistanceMetric, type Document, type DocumentInput, type EmbeddingModel, ErrorCode, type ExportRequest, type ExportResponse, type ExportedVector, type FilterExpression, type FilterOperators, type FullKnowledgeGraphRequest, type FullTextSearchResult, type HealthResponse, type HybridSearchResult, type IndexStats, type JobProgressEvent, type KeyUsage, type KnowledgeEdge, type KnowledgeGraphRequest, type KnowledgeGraphResponse, type KnowledgeNode, type LatencyAnalytics, type ListSessionsOptions, type Memory, type MemoryEvent, type MemoryFeedbackRequest, type MemoryFeedbackResponse, type MemoryId, type MemoryType, type MultiVectorSearchRequest, type MultiVectorSearchResponse, type MultiVectorSearchResult, type NamespaceCreatedEvent, type NamespaceDeletedEvent, type NamespaceInfo, NotFoundError, type OpStatus, type OperationProgressEvent, type QueryExplainRequest, type QueryExplainResponse, type QueryOptions, type QueryResult, RateLimitError, type ReadConsistency, type RecallRequest, type RecalledMemory, type SearchResult, ServerError, type Session, type SessionId, type SlowQuery, type StalenessConfig, type StartSessionRequest, type StorageAnalytics, type StoreMemoryRequest, type StoreMemoryResponse, type StreamLaggedEvent, type SummarizeRequest, type SummarizeResponse, type TextDocument, type TextQueryOptions, type TextQueryResponse, type TextSearchResult, type TextUpsertOptions, type TextUpsertResponse, type ThroughputAnalytics, TimeoutError, type TtlConfig, type UnifiedQueryRequest, type UnifiedQueryResponse, type UnifiedSearchResult, type UpdateImportanceRequest, type UpdateMemoryRequest, type UpsertOptions, type UpsertResponse, ValidationError, type Vector, type VectorId, type VectorInput, type VectorMutationOp, type VectorsMutatedEvent, type WarmCacheRequest, type WarmCacheResponse, type WarmingPriority, type WarmingTargetTier, agentId, memoryId, sessionId, vectorId };
package/dist/index.js CHANGED
@@ -21,9 +21,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
23
  AuthenticationError: () => AuthenticationError,
24
+ AuthorizationError: () => AuthorizationError,
24
25
  ConnectionError: () => ConnectionError,
25
26
  DakeraClient: () => DakeraClient,
26
27
  DakeraError: () => DakeraError,
28
+ ErrorCode: () => ErrorCode,
27
29
  NotFoundError: () => NotFoundError,
28
30
  RateLimitError: () => RateLimitError,
29
31
  ServerError: () => ServerError,
@@ -37,14 +39,34 @@ __export(index_exports, {
37
39
  module.exports = __toCommonJS(index_exports);
38
40
 
39
41
  // src/errors.ts
42
+ var ErrorCode = /* @__PURE__ */ ((ErrorCode2) => {
43
+ ErrorCode2["NAMESPACE_NOT_FOUND"] = "NAMESPACE_NOT_FOUND";
44
+ ErrorCode2["VECTOR_NOT_FOUND"] = "VECTOR_NOT_FOUND";
45
+ ErrorCode2["DIMENSION_MISMATCH"] = "DIMENSION_MISMATCH";
46
+ ErrorCode2["EMPTY_VECTOR"] = "EMPTY_VECTOR";
47
+ ErrorCode2["INVALID_REQUEST"] = "INVALID_REQUEST";
48
+ ErrorCode2["STORAGE_ERROR"] = "STORAGE_ERROR";
49
+ ErrorCode2["INTERNAL_ERROR"] = "INTERNAL_ERROR";
50
+ ErrorCode2["QUOTA_EXCEEDED"] = "QUOTA_EXCEEDED";
51
+ ErrorCode2["SERVICE_UNAVAILABLE"] = "SERVICE_UNAVAILABLE";
52
+ ErrorCode2["AUTHENTICATION_REQUIRED"] = "AUTHENTICATION_REQUIRED";
53
+ ErrorCode2["INVALID_API_KEY"] = "INVALID_API_KEY";
54
+ ErrorCode2["API_KEY_EXPIRED"] = "API_KEY_EXPIRED";
55
+ ErrorCode2["INSUFFICIENT_SCOPE"] = "INSUFFICIENT_SCOPE";
56
+ ErrorCode2["NAMESPACE_ACCESS_DENIED"] = "NAMESPACE_ACCESS_DENIED";
57
+ ErrorCode2["UNKNOWN"] = "UNKNOWN";
58
+ return ErrorCode2;
59
+ })(ErrorCode || {});
40
60
  var DakeraError = class _DakeraError extends Error {
41
61
  statusCode;
42
62
  responseBody;
43
- constructor(message, statusCode, responseBody) {
63
+ code;
64
+ constructor(message, statusCode, responseBody, code) {
44
65
  super(message);
45
66
  this.name = "DakeraError";
46
67
  this.statusCode = statusCode;
47
68
  this.responseBody = responseBody;
69
+ this.code = code;
48
70
  Object.setPrototypeOf(this, _DakeraError.prototype);
49
71
  }
50
72
  };
@@ -56,42 +78,49 @@ var ConnectionError = class _ConnectionError extends DakeraError {
56
78
  }
57
79
  };
58
80
  var NotFoundError = class _NotFoundError extends DakeraError {
59
- constructor(message, statusCode, responseBody) {
60
- super(message, statusCode, responseBody);
81
+ constructor(message, statusCode, responseBody, code) {
82
+ super(message, statusCode, responseBody, code);
61
83
  this.name = "NotFoundError";
62
84
  Object.setPrototypeOf(this, _NotFoundError.prototype);
63
85
  }
64
86
  };
65
87
  var ValidationError = class _ValidationError extends DakeraError {
66
- constructor(message, statusCode, responseBody) {
67
- super(message, statusCode, responseBody);
88
+ constructor(message, statusCode, responseBody, code) {
89
+ super(message, statusCode, responseBody, code);
68
90
  this.name = "ValidationError";
69
91
  Object.setPrototypeOf(this, _ValidationError.prototype);
70
92
  }
71
93
  };
72
94
  var RateLimitError = class _RateLimitError extends DakeraError {
73
95
  retryAfter;
74
- constructor(message, statusCode, responseBody, retryAfter) {
75
- super(message, statusCode, responseBody);
96
+ constructor(message, statusCode, responseBody, retryAfter, code) {
97
+ super(message, statusCode, responseBody, code);
76
98
  this.name = "RateLimitError";
77
99
  this.retryAfter = retryAfter;
78
100
  Object.setPrototypeOf(this, _RateLimitError.prototype);
79
101
  }
80
102
  };
81
103
  var ServerError = class _ServerError extends DakeraError {
82
- constructor(message, statusCode, responseBody) {
83
- super(message, statusCode, responseBody);
104
+ constructor(message, statusCode, responseBody, code) {
105
+ super(message, statusCode, responseBody, code);
84
106
  this.name = "ServerError";
85
107
  Object.setPrototypeOf(this, _ServerError.prototype);
86
108
  }
87
109
  };
88
110
  var AuthenticationError = class _AuthenticationError extends DakeraError {
89
- constructor(message, statusCode, responseBody) {
90
- super(message, statusCode, responseBody);
111
+ constructor(message, statusCode, responseBody, code) {
112
+ super(message, statusCode, responseBody, code);
91
113
  this.name = "AuthenticationError";
92
114
  Object.setPrototypeOf(this, _AuthenticationError.prototype);
93
115
  }
94
116
  };
117
+ var AuthorizationError = class _AuthorizationError extends DakeraError {
118
+ constructor(message, statusCode, responseBody, code) {
119
+ super(message, statusCode, responseBody, code);
120
+ this.name = "AuthorizationError";
121
+ Object.setPrototypeOf(this, _AuthorizationError.prototype);
122
+ }
123
+ };
95
124
  var TimeoutError = class _TimeoutError extends DakeraError {
96
125
  constructor(message) {
97
126
  super(message);
@@ -101,6 +130,12 @@ var TimeoutError = class _TimeoutError extends DakeraError {
101
130
  };
102
131
 
103
132
  // src/client.ts
133
+ function parseErrorCode(raw) {
134
+ if (typeof raw === "string" && raw in ErrorCode) {
135
+ return raw;
136
+ }
137
+ return "UNKNOWN" /* UNKNOWN */;
138
+ }
104
139
  var DEFAULT_OPTIONS = {
105
140
  baseUrl: "http://localhost:3000",
106
141
  timeout: 3e4,
@@ -183,27 +218,33 @@ var DakeraClient = class {
183
218
  return body;
184
219
  }
185
220
  const errorMessage = typeof body === "object" && body !== null && "error" in body ? String(body.error) : typeof body === "string" ? body : `HTTP ${response.status}`;
221
+ const code = parseErrorCode(
222
+ typeof body === "object" && body !== null && "code" in body ? body.code : void 0
223
+ );
186
224
  switch (response.status) {
187
225
  case 400:
188
- throw new ValidationError(errorMessage, response.status, body);
226
+ throw new ValidationError(errorMessage, response.status, body, code);
189
227
  case 401:
190
- throw new AuthenticationError("Authentication failed", response.status, body);
228
+ throw new AuthenticationError("Authentication failed", response.status, body, code);
229
+ case 403:
230
+ throw new AuthorizationError(errorMessage, response.status, body, code);
191
231
  case 404:
192
- throw new NotFoundError(errorMessage, response.status, body);
232
+ throw new NotFoundError(errorMessage, response.status, body, code);
193
233
  case 429: {
194
234
  const retryAfter = response.headers.get("Retry-After");
195
235
  throw new RateLimitError(
196
236
  "Rate limit exceeded",
197
237
  response.status,
198
238
  body,
199
- retryAfter ? parseInt(retryAfter, 10) : void 0
239
+ retryAfter ? parseInt(retryAfter, 10) : void 0,
240
+ code
200
241
  );
201
242
  }
202
243
  default:
203
244
  if (response.status >= 500) {
204
- throw new ServerError(errorMessage, response.status, body);
245
+ throw new ServerError(errorMessage, response.status, body, code);
205
246
  }
206
- throw new DakeraError(errorMessage, response.status, body);
247
+ throw new DakeraError(errorMessage, response.status, body, code);
207
248
  }
208
249
  }
209
250
  sleep(ms) {
@@ -473,6 +514,19 @@ var DakeraClient = class {
473
514
  if (options.metadata) body.metadata = options.metadata;
474
515
  return this.request("POST", "/v1/namespaces", body);
475
516
  }
517
+ /**
518
+ * Create or update a namespace configuration (upsert semantics).
519
+ *
520
+ * Creates the namespace if it does not exist, or updates its configuration
521
+ * if it already exists. Requires Write scope.
522
+ *
523
+ * @param namespace - Namespace name
524
+ * @param request - dimension and optional distance metric
525
+ * @returns ConfigureNamespaceResponse with ``created: true`` if newly created
526
+ */
527
+ async configureNamespace(namespace, request) {
528
+ return this.request("PUT", `/v1/namespaces/${namespace}`, request);
529
+ }
476
530
  /**
477
531
  * Delete a namespace.
478
532
  *
@@ -1411,9 +1465,11 @@ function sessionId(id) {
1411
1465
  // Annotate the CommonJS export names for ESM import in node:
1412
1466
  0 && (module.exports = {
1413
1467
  AuthenticationError,
1468
+ AuthorizationError,
1414
1469
  ConnectionError,
1415
1470
  DakeraClient,
1416
1471
  DakeraError,
1472
+ ErrorCode,
1417
1473
  NotFoundError,
1418
1474
  RateLimitError,
1419
1475
  ServerError,
package/dist/index.mjs CHANGED
@@ -1,12 +1,32 @@
1
1
  // src/errors.ts
2
+ var ErrorCode = /* @__PURE__ */ ((ErrorCode2) => {
3
+ ErrorCode2["NAMESPACE_NOT_FOUND"] = "NAMESPACE_NOT_FOUND";
4
+ ErrorCode2["VECTOR_NOT_FOUND"] = "VECTOR_NOT_FOUND";
5
+ ErrorCode2["DIMENSION_MISMATCH"] = "DIMENSION_MISMATCH";
6
+ ErrorCode2["EMPTY_VECTOR"] = "EMPTY_VECTOR";
7
+ ErrorCode2["INVALID_REQUEST"] = "INVALID_REQUEST";
8
+ ErrorCode2["STORAGE_ERROR"] = "STORAGE_ERROR";
9
+ ErrorCode2["INTERNAL_ERROR"] = "INTERNAL_ERROR";
10
+ ErrorCode2["QUOTA_EXCEEDED"] = "QUOTA_EXCEEDED";
11
+ ErrorCode2["SERVICE_UNAVAILABLE"] = "SERVICE_UNAVAILABLE";
12
+ ErrorCode2["AUTHENTICATION_REQUIRED"] = "AUTHENTICATION_REQUIRED";
13
+ ErrorCode2["INVALID_API_KEY"] = "INVALID_API_KEY";
14
+ ErrorCode2["API_KEY_EXPIRED"] = "API_KEY_EXPIRED";
15
+ ErrorCode2["INSUFFICIENT_SCOPE"] = "INSUFFICIENT_SCOPE";
16
+ ErrorCode2["NAMESPACE_ACCESS_DENIED"] = "NAMESPACE_ACCESS_DENIED";
17
+ ErrorCode2["UNKNOWN"] = "UNKNOWN";
18
+ return ErrorCode2;
19
+ })(ErrorCode || {});
2
20
  var DakeraError = class _DakeraError extends Error {
3
21
  statusCode;
4
22
  responseBody;
5
- constructor(message, statusCode, responseBody) {
23
+ code;
24
+ constructor(message, statusCode, responseBody, code) {
6
25
  super(message);
7
26
  this.name = "DakeraError";
8
27
  this.statusCode = statusCode;
9
28
  this.responseBody = responseBody;
29
+ this.code = code;
10
30
  Object.setPrototypeOf(this, _DakeraError.prototype);
11
31
  }
12
32
  };
@@ -18,42 +38,49 @@ var ConnectionError = class _ConnectionError extends DakeraError {
18
38
  }
19
39
  };
20
40
  var NotFoundError = class _NotFoundError extends DakeraError {
21
- constructor(message, statusCode, responseBody) {
22
- super(message, statusCode, responseBody);
41
+ constructor(message, statusCode, responseBody, code) {
42
+ super(message, statusCode, responseBody, code);
23
43
  this.name = "NotFoundError";
24
44
  Object.setPrototypeOf(this, _NotFoundError.prototype);
25
45
  }
26
46
  };
27
47
  var ValidationError = class _ValidationError extends DakeraError {
28
- constructor(message, statusCode, responseBody) {
29
- super(message, statusCode, responseBody);
48
+ constructor(message, statusCode, responseBody, code) {
49
+ super(message, statusCode, responseBody, code);
30
50
  this.name = "ValidationError";
31
51
  Object.setPrototypeOf(this, _ValidationError.prototype);
32
52
  }
33
53
  };
34
54
  var RateLimitError = class _RateLimitError extends DakeraError {
35
55
  retryAfter;
36
- constructor(message, statusCode, responseBody, retryAfter) {
37
- super(message, statusCode, responseBody);
56
+ constructor(message, statusCode, responseBody, retryAfter, code) {
57
+ super(message, statusCode, responseBody, code);
38
58
  this.name = "RateLimitError";
39
59
  this.retryAfter = retryAfter;
40
60
  Object.setPrototypeOf(this, _RateLimitError.prototype);
41
61
  }
42
62
  };
43
63
  var ServerError = class _ServerError extends DakeraError {
44
- constructor(message, statusCode, responseBody) {
45
- super(message, statusCode, responseBody);
64
+ constructor(message, statusCode, responseBody, code) {
65
+ super(message, statusCode, responseBody, code);
46
66
  this.name = "ServerError";
47
67
  Object.setPrototypeOf(this, _ServerError.prototype);
48
68
  }
49
69
  };
50
70
  var AuthenticationError = class _AuthenticationError extends DakeraError {
51
- constructor(message, statusCode, responseBody) {
52
- super(message, statusCode, responseBody);
71
+ constructor(message, statusCode, responseBody, code) {
72
+ super(message, statusCode, responseBody, code);
53
73
  this.name = "AuthenticationError";
54
74
  Object.setPrototypeOf(this, _AuthenticationError.prototype);
55
75
  }
56
76
  };
77
+ var AuthorizationError = class _AuthorizationError extends DakeraError {
78
+ constructor(message, statusCode, responseBody, code) {
79
+ super(message, statusCode, responseBody, code);
80
+ this.name = "AuthorizationError";
81
+ Object.setPrototypeOf(this, _AuthorizationError.prototype);
82
+ }
83
+ };
57
84
  var TimeoutError = class _TimeoutError extends DakeraError {
58
85
  constructor(message) {
59
86
  super(message);
@@ -63,6 +90,12 @@ var TimeoutError = class _TimeoutError extends DakeraError {
63
90
  };
64
91
 
65
92
  // src/client.ts
93
+ function parseErrorCode(raw) {
94
+ if (typeof raw === "string" && raw in ErrorCode) {
95
+ return raw;
96
+ }
97
+ return "UNKNOWN" /* UNKNOWN */;
98
+ }
66
99
  var DEFAULT_OPTIONS = {
67
100
  baseUrl: "http://localhost:3000",
68
101
  timeout: 3e4,
@@ -145,27 +178,33 @@ var DakeraClient = class {
145
178
  return body;
146
179
  }
147
180
  const errorMessage = typeof body === "object" && body !== null && "error" in body ? String(body.error) : typeof body === "string" ? body : `HTTP ${response.status}`;
181
+ const code = parseErrorCode(
182
+ typeof body === "object" && body !== null && "code" in body ? body.code : void 0
183
+ );
148
184
  switch (response.status) {
149
185
  case 400:
150
- throw new ValidationError(errorMessage, response.status, body);
186
+ throw new ValidationError(errorMessage, response.status, body, code);
151
187
  case 401:
152
- throw new AuthenticationError("Authentication failed", response.status, body);
188
+ throw new AuthenticationError("Authentication failed", response.status, body, code);
189
+ case 403:
190
+ throw new AuthorizationError(errorMessage, response.status, body, code);
153
191
  case 404:
154
- throw new NotFoundError(errorMessage, response.status, body);
192
+ throw new NotFoundError(errorMessage, response.status, body, code);
155
193
  case 429: {
156
194
  const retryAfter = response.headers.get("Retry-After");
157
195
  throw new RateLimitError(
158
196
  "Rate limit exceeded",
159
197
  response.status,
160
198
  body,
161
- retryAfter ? parseInt(retryAfter, 10) : void 0
199
+ retryAfter ? parseInt(retryAfter, 10) : void 0,
200
+ code
162
201
  );
163
202
  }
164
203
  default:
165
204
  if (response.status >= 500) {
166
- throw new ServerError(errorMessage, response.status, body);
205
+ throw new ServerError(errorMessage, response.status, body, code);
167
206
  }
168
- throw new DakeraError(errorMessage, response.status, body);
207
+ throw new DakeraError(errorMessage, response.status, body, code);
169
208
  }
170
209
  }
171
210
  sleep(ms) {
@@ -435,6 +474,19 @@ var DakeraClient = class {
435
474
  if (options.metadata) body.metadata = options.metadata;
436
475
  return this.request("POST", "/v1/namespaces", body);
437
476
  }
477
+ /**
478
+ * Create or update a namespace configuration (upsert semantics).
479
+ *
480
+ * Creates the namespace if it does not exist, or updates its configuration
481
+ * if it already exists. Requires Write scope.
482
+ *
483
+ * @param namespace - Namespace name
484
+ * @param request - dimension and optional distance metric
485
+ * @returns ConfigureNamespaceResponse with ``created: true`` if newly created
486
+ */
487
+ async configureNamespace(namespace, request) {
488
+ return this.request("PUT", `/v1/namespaces/${namespace}`, request);
489
+ }
438
490
  /**
439
491
  * Delete a namespace.
440
492
  *
@@ -1372,9 +1424,11 @@ function sessionId(id) {
1372
1424
  }
1373
1425
  export {
1374
1426
  AuthenticationError,
1427
+ AuthorizationError,
1375
1428
  ConnectionError,
1376
1429
  DakeraClient,
1377
1430
  DakeraError,
1431
+ ErrorCode,
1378
1432
  NotFoundError,
1379
1433
  RateLimitError,
1380
1434
  ServerError,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dakera-ai/dakera",
3
- "version": "0.5.0",
3
+ "version": "0.6.1",
4
4
  "description": "TypeScript/JavaScript SDK for Dakera AI memory platform",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",