@dakera-ai/dakera 0.3.0 → 0.5.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
@@ -823,6 +823,138 @@ interface ColumnUpsertRequest {
823
823
  /** Expected dimension */
824
824
  dimension?: number;
825
825
  }
826
+ /** Operation status for ``operation_progress`` events. */
827
+ type OpStatus = 'pending' | 'running' | 'completed' | 'failed';
828
+ /** Vector mutation operation type for ``vectors_mutated`` events. */
829
+ type VectorMutationOp = 'upserted' | 'deleted';
830
+ /** A namespace was created. */
831
+ interface NamespaceCreatedEvent {
832
+ type: 'namespace_created';
833
+ namespace: string;
834
+ dimension: number;
835
+ }
836
+ /** A namespace was deleted. */
837
+ interface NamespaceDeletedEvent {
838
+ type: 'namespace_deleted';
839
+ namespace: string;
840
+ }
841
+ /** Progress update for a long-running operation (0–100). */
842
+ interface OperationProgressEvent {
843
+ type: 'operation_progress';
844
+ operation_id: string;
845
+ namespace?: string;
846
+ op_type: string;
847
+ /** Progress percentage 0–100 */
848
+ progress: number;
849
+ status: OpStatus;
850
+ message?: string;
851
+ /** Unix milliseconds */
852
+ updated_at: number;
853
+ }
854
+ /** A background job changed status. */
855
+ interface JobProgressEvent {
856
+ type: 'job_progress';
857
+ job_id: string;
858
+ job_type: string;
859
+ namespace?: string;
860
+ progress: number;
861
+ status: string;
862
+ }
863
+ /** Vectors were upserted or deleted in bulk (threshold: >100 vectors). */
864
+ interface VectorsMutatedEvent {
865
+ type: 'vectors_mutated';
866
+ namespace: string;
867
+ op: VectorMutationOp;
868
+ count: number;
869
+ }
870
+ /**
871
+ * Subscriber fell too far behind — some events were dropped.
872
+ * Reconnect to resume the stream.
873
+ */
874
+ interface StreamLaggedEvent {
875
+ type: 'stream_lagged';
876
+ dropped: number;
877
+ hint: string;
878
+ }
879
+ /** Union of all Dakera SSE event types. */
880
+ type DakeraEvent = NamespaceCreatedEvent | NamespaceDeletedEvent | OperationProgressEvent | JobProgressEvent | VectorsMutatedEvent | StreamLaggedEvent;
881
+ /**
882
+ * A memory lifecycle event emitted on the agent memory SSE stream.
883
+ *
884
+ * event_type values:
885
+ * stored | recalled | forgotten | consolidated |
886
+ * importance_updated | session_started | session_ended
887
+ */
888
+ interface MemoryEvent {
889
+ /** Memory lifecycle event type */
890
+ event_type: string;
891
+ /** Agent that owns the memory */
892
+ agent_id: string;
893
+ /** Unix milliseconds */
894
+ timestamp: number;
895
+ /** Memory ID (present for most event types) */
896
+ memory_id?: string;
897
+ /** Memory content snapshot */
898
+ content?: string;
899
+ /** Importance score at the time of the event */
900
+ importance?: number;
901
+ /** Tags associated with the memory */
902
+ tags?: string[];
903
+ /** Session ID (present for session_started / session_ended events) */
904
+ session_id?: string;
905
+ }
906
+ /** Summary info for one agent in the cross-agent network */
907
+ interface AgentNetworkInfo {
908
+ agent_id: string;
909
+ memory_count: number;
910
+ avg_importance: number;
911
+ }
912
+ /** A node in the cross-agent memory network graph */
913
+ interface AgentNetworkNode {
914
+ id: string;
915
+ agent_id: string;
916
+ content: string;
917
+ importance: number;
918
+ tags: string[];
919
+ memory_type: string;
920
+ /** Unix milliseconds */
921
+ created_at: number;
922
+ }
923
+ /** A cross-agent similarity edge */
924
+ interface AgentNetworkEdge {
925
+ source: string;
926
+ target: string;
927
+ source_agent: string;
928
+ target_agent: string;
929
+ similarity: number;
930
+ }
931
+ /** Aggregate statistics for the cross-agent network */
932
+ interface AgentNetworkStats {
933
+ total_agents: number;
934
+ total_nodes: number;
935
+ total_cross_edges: number;
936
+ density: number;
937
+ }
938
+ /** Response from the cross-agent network endpoint */
939
+ interface CrossAgentNetworkResponse {
940
+ agents: AgentNetworkInfo[];
941
+ nodes: AgentNetworkNode[];
942
+ edges: AgentNetworkEdge[];
943
+ stats: AgentNetworkStats;
944
+ }
945
+ /** Request body for POST /v1/knowledge/network/cross-agent */
946
+ interface CrossAgentNetworkRequest {
947
+ /** Agent IDs to include — undefined means all agents */
948
+ agent_ids?: string[];
949
+ /** Minimum similarity threshold for edges (default 0.3) */
950
+ min_similarity?: number;
951
+ /** Maximum nodes to include per agent (default 50) */
952
+ max_nodes_per_agent?: number;
953
+ /** Minimum importance for a node to be included (default 0.0) */
954
+ min_importance?: number;
955
+ /** Maximum cross-agent edges to return (default 200) */
956
+ max_cross_edges?: number;
957
+ }
826
958
  /** Cluster status response */
827
959
  interface ClusterStatus {
828
960
  status: string;
@@ -1435,6 +1567,22 @@ declare class DakeraClient {
1435
1567
  summarize(request: SummarizeRequest): Promise<SummarizeResponse>;
1436
1568
  /** Deduplicate memories */
1437
1569
  deduplicate(request: DeduplicateRequest): Promise<DeduplicateResponse>;
1570
+ /**
1571
+ * Build a cross-agent memory network graph (DASH-A).
1572
+ *
1573
+ * Calls `POST /v1/knowledge/network/cross-agent` and returns a graph
1574
+ * containing every agent's nodes and the cross-agent similarity edges that
1575
+ * connect them.
1576
+ *
1577
+ * Requires an Admin-scoped API key.
1578
+ *
1579
+ * @example
1580
+ * ```ts
1581
+ * const network = await client.crossAgentNetwork({ min_similarity: 0.5 });
1582
+ * console.log(`${network.stats.total_cross_edges} cross-agent edges`);
1583
+ * ```
1584
+ */
1585
+ crossAgentNetwork(req?: CrossAgentNetworkRequest): Promise<CrossAgentNetworkResponse>;
1438
1586
  /** Get analytics overview */
1439
1587
  analyticsOverview(options?: AnalyticsOptions): Promise<AnalyticsOverview>;
1440
1588
  /** Get latency analytics */
@@ -1506,6 +1654,74 @@ declare class DakeraClient {
1506
1654
  rotateKey(keyId: string): Promise<ApiKey>;
1507
1655
  /** Get usage statistics for an API key */
1508
1656
  keyUsage(keyId: string): Promise<KeyUsage>;
1657
+ /**
1658
+ * Stream SSE events scoped to a namespace.
1659
+ *
1660
+ * Opens a long-lived connection to `GET /v1/namespaces/{namespace}/events`
1661
+ * and yields {@link DakeraEvent} objects as they arrive. The async
1662
+ * generator runs until the connection closes or the caller breaks the loop.
1663
+ *
1664
+ * Requires a Read-scoped API key.
1665
+ *
1666
+ * @example
1667
+ * ```ts
1668
+ * for await (const event of client.streamNamespaceEvents('my-ns')) {
1669
+ * if (event.type === 'vectors_mutated') {
1670
+ * console.log(`${event.count} vectors ${event.op} in ${event.namespace}`);
1671
+ * }
1672
+ * }
1673
+ * ```
1674
+ */
1675
+ streamNamespaceEvents(namespace: string): AsyncGenerator<DakeraEvent>;
1676
+ /**
1677
+ * Stream all system events from the global event bus.
1678
+ *
1679
+ * Opens a long-lived connection to `GET /ops/events` and yields
1680
+ * {@link DakeraEvent} objects as they arrive.
1681
+ *
1682
+ * Requires an Admin-scoped API key.
1683
+ *
1684
+ * @example
1685
+ * ```ts
1686
+ * for await (const event of client.streamGlobalEvents()) {
1687
+ * console.log(event.type, event);
1688
+ * }
1689
+ * ```
1690
+ */
1691
+ streamGlobalEvents(): AsyncGenerator<DakeraEvent>;
1692
+ /**
1693
+ * Stream memory lifecycle events for all agents (DASH-B).
1694
+ *
1695
+ * Opens a long-lived connection to `GET /v1/events/stream` and yields
1696
+ * {@link MemoryEvent} objects as they arrive. Each SSE frame uses the
1697
+ * `event:` field for the event_type and a JSON `data:` payload.
1698
+ *
1699
+ * Requires a Read-scoped API key.
1700
+ *
1701
+ * @example
1702
+ * ```ts
1703
+ * for await (const ev of client.streamMemoryEvents()) {
1704
+ * if (ev.event_type === 'stored') {
1705
+ * console.log(`Memory stored for agent ${ev.agent_id}: ${ev.content}`);
1706
+ * }
1707
+ * }
1708
+ * ```
1709
+ */
1710
+ streamMemoryEvents(): AsyncGenerator<MemoryEvent>;
1711
+ /** Low-level SSE streaming helper — parses the SSE wire format. */
1712
+ private _streamSse;
1713
+ /** Parse a single SSE event block into a {@link DakeraEvent}. */
1714
+ private _parseSseBlock;
1715
+ /**
1716
+ * Low-level SSE streaming helper for the memory event stream.
1717
+ *
1718
+ * The memory event stream sets the SSE `event:` field to the event_type
1719
+ * and the `data:` field to the JSON payload. This helper merges the two
1720
+ * so callers receive a fully-populated {@link MemoryEvent}.
1721
+ */
1722
+ private _streamSseMemory;
1723
+ /** Parse a single SSE event block into a {@link MemoryEvent}. */
1724
+ private _parseSseMemoryBlock;
1509
1725
  }
1510
1726
 
1511
1727
  /**
@@ -1547,4 +1763,4 @@ declare class TimeoutError extends DakeraError {
1547
1763
  constructor(message: string);
1548
1764
  }
1549
1765
 
1550
- export { type AccessPatternHint, type AgentId, 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, DakeraClient, DakeraError, 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 KeyUsage, type KnowledgeEdge, type KnowledgeGraphRequest, type KnowledgeGraphResponse, type KnowledgeNode, type LatencyAnalytics, type ListSessionsOptions, type Memory, type MemoryFeedbackRequest, type MemoryFeedbackResponse, type MemoryId, type MemoryType, type MultiVectorSearchRequest, type MultiVectorSearchResponse, type MultiVectorSearchResult, type NamespaceInfo, NotFoundError, 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 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 WarmCacheRequest, type WarmCacheResponse, type WarmingPriority, type WarmingTargetTier, agentId, memoryId, sessionId, vectorId };
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 };
package/dist/index.d.ts CHANGED
@@ -823,6 +823,138 @@ interface ColumnUpsertRequest {
823
823
  /** Expected dimension */
824
824
  dimension?: number;
825
825
  }
826
+ /** Operation status for ``operation_progress`` events. */
827
+ type OpStatus = 'pending' | 'running' | 'completed' | 'failed';
828
+ /** Vector mutation operation type for ``vectors_mutated`` events. */
829
+ type VectorMutationOp = 'upserted' | 'deleted';
830
+ /** A namespace was created. */
831
+ interface NamespaceCreatedEvent {
832
+ type: 'namespace_created';
833
+ namespace: string;
834
+ dimension: number;
835
+ }
836
+ /** A namespace was deleted. */
837
+ interface NamespaceDeletedEvent {
838
+ type: 'namespace_deleted';
839
+ namespace: string;
840
+ }
841
+ /** Progress update for a long-running operation (0–100). */
842
+ interface OperationProgressEvent {
843
+ type: 'operation_progress';
844
+ operation_id: string;
845
+ namespace?: string;
846
+ op_type: string;
847
+ /** Progress percentage 0–100 */
848
+ progress: number;
849
+ status: OpStatus;
850
+ message?: string;
851
+ /** Unix milliseconds */
852
+ updated_at: number;
853
+ }
854
+ /** A background job changed status. */
855
+ interface JobProgressEvent {
856
+ type: 'job_progress';
857
+ job_id: string;
858
+ job_type: string;
859
+ namespace?: string;
860
+ progress: number;
861
+ status: string;
862
+ }
863
+ /** Vectors were upserted or deleted in bulk (threshold: >100 vectors). */
864
+ interface VectorsMutatedEvent {
865
+ type: 'vectors_mutated';
866
+ namespace: string;
867
+ op: VectorMutationOp;
868
+ count: number;
869
+ }
870
+ /**
871
+ * Subscriber fell too far behind — some events were dropped.
872
+ * Reconnect to resume the stream.
873
+ */
874
+ interface StreamLaggedEvent {
875
+ type: 'stream_lagged';
876
+ dropped: number;
877
+ hint: string;
878
+ }
879
+ /** Union of all Dakera SSE event types. */
880
+ type DakeraEvent = NamespaceCreatedEvent | NamespaceDeletedEvent | OperationProgressEvent | JobProgressEvent | VectorsMutatedEvent | StreamLaggedEvent;
881
+ /**
882
+ * A memory lifecycle event emitted on the agent memory SSE stream.
883
+ *
884
+ * event_type values:
885
+ * stored | recalled | forgotten | consolidated |
886
+ * importance_updated | session_started | session_ended
887
+ */
888
+ interface MemoryEvent {
889
+ /** Memory lifecycle event type */
890
+ event_type: string;
891
+ /** Agent that owns the memory */
892
+ agent_id: string;
893
+ /** Unix milliseconds */
894
+ timestamp: number;
895
+ /** Memory ID (present for most event types) */
896
+ memory_id?: string;
897
+ /** Memory content snapshot */
898
+ content?: string;
899
+ /** Importance score at the time of the event */
900
+ importance?: number;
901
+ /** Tags associated with the memory */
902
+ tags?: string[];
903
+ /** Session ID (present for session_started / session_ended events) */
904
+ session_id?: string;
905
+ }
906
+ /** Summary info for one agent in the cross-agent network */
907
+ interface AgentNetworkInfo {
908
+ agent_id: string;
909
+ memory_count: number;
910
+ avg_importance: number;
911
+ }
912
+ /** A node in the cross-agent memory network graph */
913
+ interface AgentNetworkNode {
914
+ id: string;
915
+ agent_id: string;
916
+ content: string;
917
+ importance: number;
918
+ tags: string[];
919
+ memory_type: string;
920
+ /** Unix milliseconds */
921
+ created_at: number;
922
+ }
923
+ /** A cross-agent similarity edge */
924
+ interface AgentNetworkEdge {
925
+ source: string;
926
+ target: string;
927
+ source_agent: string;
928
+ target_agent: string;
929
+ similarity: number;
930
+ }
931
+ /** Aggregate statistics for the cross-agent network */
932
+ interface AgentNetworkStats {
933
+ total_agents: number;
934
+ total_nodes: number;
935
+ total_cross_edges: number;
936
+ density: number;
937
+ }
938
+ /** Response from the cross-agent network endpoint */
939
+ interface CrossAgentNetworkResponse {
940
+ agents: AgentNetworkInfo[];
941
+ nodes: AgentNetworkNode[];
942
+ edges: AgentNetworkEdge[];
943
+ stats: AgentNetworkStats;
944
+ }
945
+ /** Request body for POST /v1/knowledge/network/cross-agent */
946
+ interface CrossAgentNetworkRequest {
947
+ /** Agent IDs to include — undefined means all agents */
948
+ agent_ids?: string[];
949
+ /** Minimum similarity threshold for edges (default 0.3) */
950
+ min_similarity?: number;
951
+ /** Maximum nodes to include per agent (default 50) */
952
+ max_nodes_per_agent?: number;
953
+ /** Minimum importance for a node to be included (default 0.0) */
954
+ min_importance?: number;
955
+ /** Maximum cross-agent edges to return (default 200) */
956
+ max_cross_edges?: number;
957
+ }
826
958
  /** Cluster status response */
827
959
  interface ClusterStatus {
828
960
  status: string;
@@ -1435,6 +1567,22 @@ declare class DakeraClient {
1435
1567
  summarize(request: SummarizeRequest): Promise<SummarizeResponse>;
1436
1568
  /** Deduplicate memories */
1437
1569
  deduplicate(request: DeduplicateRequest): Promise<DeduplicateResponse>;
1570
+ /**
1571
+ * Build a cross-agent memory network graph (DASH-A).
1572
+ *
1573
+ * Calls `POST /v1/knowledge/network/cross-agent` and returns a graph
1574
+ * containing every agent's nodes and the cross-agent similarity edges that
1575
+ * connect them.
1576
+ *
1577
+ * Requires an Admin-scoped API key.
1578
+ *
1579
+ * @example
1580
+ * ```ts
1581
+ * const network = await client.crossAgentNetwork({ min_similarity: 0.5 });
1582
+ * console.log(`${network.stats.total_cross_edges} cross-agent edges`);
1583
+ * ```
1584
+ */
1585
+ crossAgentNetwork(req?: CrossAgentNetworkRequest): Promise<CrossAgentNetworkResponse>;
1438
1586
  /** Get analytics overview */
1439
1587
  analyticsOverview(options?: AnalyticsOptions): Promise<AnalyticsOverview>;
1440
1588
  /** Get latency analytics */
@@ -1506,6 +1654,74 @@ declare class DakeraClient {
1506
1654
  rotateKey(keyId: string): Promise<ApiKey>;
1507
1655
  /** Get usage statistics for an API key */
1508
1656
  keyUsage(keyId: string): Promise<KeyUsage>;
1657
+ /**
1658
+ * Stream SSE events scoped to a namespace.
1659
+ *
1660
+ * Opens a long-lived connection to `GET /v1/namespaces/{namespace}/events`
1661
+ * and yields {@link DakeraEvent} objects as they arrive. The async
1662
+ * generator runs until the connection closes or the caller breaks the loop.
1663
+ *
1664
+ * Requires a Read-scoped API key.
1665
+ *
1666
+ * @example
1667
+ * ```ts
1668
+ * for await (const event of client.streamNamespaceEvents('my-ns')) {
1669
+ * if (event.type === 'vectors_mutated') {
1670
+ * console.log(`${event.count} vectors ${event.op} in ${event.namespace}`);
1671
+ * }
1672
+ * }
1673
+ * ```
1674
+ */
1675
+ streamNamespaceEvents(namespace: string): AsyncGenerator<DakeraEvent>;
1676
+ /**
1677
+ * Stream all system events from the global event bus.
1678
+ *
1679
+ * Opens a long-lived connection to `GET /ops/events` and yields
1680
+ * {@link DakeraEvent} objects as they arrive.
1681
+ *
1682
+ * Requires an Admin-scoped API key.
1683
+ *
1684
+ * @example
1685
+ * ```ts
1686
+ * for await (const event of client.streamGlobalEvents()) {
1687
+ * console.log(event.type, event);
1688
+ * }
1689
+ * ```
1690
+ */
1691
+ streamGlobalEvents(): AsyncGenerator<DakeraEvent>;
1692
+ /**
1693
+ * Stream memory lifecycle events for all agents (DASH-B).
1694
+ *
1695
+ * Opens a long-lived connection to `GET /v1/events/stream` and yields
1696
+ * {@link MemoryEvent} objects as they arrive. Each SSE frame uses the
1697
+ * `event:` field for the event_type and a JSON `data:` payload.
1698
+ *
1699
+ * Requires a Read-scoped API key.
1700
+ *
1701
+ * @example
1702
+ * ```ts
1703
+ * for await (const ev of client.streamMemoryEvents()) {
1704
+ * if (ev.event_type === 'stored') {
1705
+ * console.log(`Memory stored for agent ${ev.agent_id}: ${ev.content}`);
1706
+ * }
1707
+ * }
1708
+ * ```
1709
+ */
1710
+ streamMemoryEvents(): AsyncGenerator<MemoryEvent>;
1711
+ /** Low-level SSE streaming helper — parses the SSE wire format. */
1712
+ private _streamSse;
1713
+ /** Parse a single SSE event block into a {@link DakeraEvent}. */
1714
+ private _parseSseBlock;
1715
+ /**
1716
+ * Low-level SSE streaming helper for the memory event stream.
1717
+ *
1718
+ * The memory event stream sets the SSE `event:` field to the event_type
1719
+ * and the `data:` field to the JSON payload. This helper merges the two
1720
+ * so callers receive a fully-populated {@link MemoryEvent}.
1721
+ */
1722
+ private _streamSseMemory;
1723
+ /** Parse a single SSE event block into a {@link MemoryEvent}. */
1724
+ private _parseSseMemoryBlock;
1509
1725
  }
1510
1726
 
1511
1727
  /**
@@ -1547,4 +1763,4 @@ declare class TimeoutError extends DakeraError {
1547
1763
  constructor(message: string);
1548
1764
  }
1549
1765
 
1550
- export { type AccessPatternHint, type AgentId, 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, DakeraClient, DakeraError, 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 KeyUsage, type KnowledgeEdge, type KnowledgeGraphRequest, type KnowledgeGraphResponse, type KnowledgeNode, type LatencyAnalytics, type ListSessionsOptions, type Memory, type MemoryFeedbackRequest, type MemoryFeedbackResponse, type MemoryId, type MemoryType, type MultiVectorSearchRequest, type MultiVectorSearchResponse, type MultiVectorSearchResult, type NamespaceInfo, NotFoundError, 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 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 WarmCacheRequest, type WarmCacheResponse, type WarmingPriority, type WarmingTargetTier, agentId, memoryId, sessionId, vectorId };
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 };
package/dist/index.js CHANGED
@@ -1056,6 +1056,28 @@ var DakeraClient = class {
1056
1056
  async deduplicate(request) {
1057
1057
  return this.request("POST", "/v1/knowledge/deduplicate", request);
1058
1058
  }
1059
+ /**
1060
+ * Build a cross-agent memory network graph (DASH-A).
1061
+ *
1062
+ * Calls `POST /v1/knowledge/network/cross-agent` and returns a graph
1063
+ * containing every agent's nodes and the cross-agent similarity edges that
1064
+ * connect them.
1065
+ *
1066
+ * Requires an Admin-scoped API key.
1067
+ *
1068
+ * @example
1069
+ * ```ts
1070
+ * const network = await client.crossAgentNetwork({ min_similarity: 0.5 });
1071
+ * console.log(`${network.stats.total_cross_edges} cross-agent edges`);
1072
+ * ```
1073
+ */
1074
+ async crossAgentNetwork(req) {
1075
+ return this.request(
1076
+ "POST",
1077
+ "/v1/knowledge/network/cross-agent",
1078
+ req ?? {}
1079
+ );
1080
+ }
1059
1081
  // ===========================================================================
1060
1082
  // Analytics Operations
1061
1083
  // ===========================================================================
@@ -1199,6 +1221,178 @@ var DakeraClient = class {
1199
1221
  async keyUsage(keyId) {
1200
1222
  return this.request("GET", `/v1/keys/${keyId}/usage`);
1201
1223
  }
1224
+ // ===========================================================================
1225
+ // SSE Streaming (CE-1)
1226
+ // ===========================================================================
1227
+ /**
1228
+ * Stream SSE events scoped to a namespace.
1229
+ *
1230
+ * Opens a long-lived connection to `GET /v1/namespaces/{namespace}/events`
1231
+ * and yields {@link DakeraEvent} objects as they arrive. The async
1232
+ * generator runs until the connection closes or the caller breaks the loop.
1233
+ *
1234
+ * Requires a Read-scoped API key.
1235
+ *
1236
+ * @example
1237
+ * ```ts
1238
+ * for await (const event of client.streamNamespaceEvents('my-ns')) {
1239
+ * if (event.type === 'vectors_mutated') {
1240
+ * console.log(`${event.count} vectors ${event.op} in ${event.namespace}`);
1241
+ * }
1242
+ * }
1243
+ * ```
1244
+ */
1245
+ async *streamNamespaceEvents(namespace) {
1246
+ const url = `${this.baseUrl}/v1/namespaces/${encodeURIComponent(namespace)}/events`;
1247
+ yield* this._streamSse(url);
1248
+ }
1249
+ /**
1250
+ * Stream all system events from the global event bus.
1251
+ *
1252
+ * Opens a long-lived connection to `GET /ops/events` and yields
1253
+ * {@link DakeraEvent} objects as they arrive.
1254
+ *
1255
+ * Requires an Admin-scoped API key.
1256
+ *
1257
+ * @example
1258
+ * ```ts
1259
+ * for await (const event of client.streamGlobalEvents()) {
1260
+ * console.log(event.type, event);
1261
+ * }
1262
+ * ```
1263
+ */
1264
+ async *streamGlobalEvents() {
1265
+ const url = `${this.baseUrl}/ops/events`;
1266
+ yield* this._streamSse(url);
1267
+ }
1268
+ /**
1269
+ * Stream memory lifecycle events for all agents (DASH-B).
1270
+ *
1271
+ * Opens a long-lived connection to `GET /v1/events/stream` and yields
1272
+ * {@link MemoryEvent} objects as they arrive. Each SSE frame uses the
1273
+ * `event:` field for the event_type and a JSON `data:` payload.
1274
+ *
1275
+ * Requires a Read-scoped API key.
1276
+ *
1277
+ * @example
1278
+ * ```ts
1279
+ * for await (const ev of client.streamMemoryEvents()) {
1280
+ * if (ev.event_type === 'stored') {
1281
+ * console.log(`Memory stored for agent ${ev.agent_id}: ${ev.content}`);
1282
+ * }
1283
+ * }
1284
+ * ```
1285
+ */
1286
+ async *streamMemoryEvents() {
1287
+ const url = `${this.baseUrl}/v1/events/stream`;
1288
+ yield* this._streamSseMemory(url);
1289
+ }
1290
+ /** Low-level SSE streaming helper — parses the SSE wire format. */
1291
+ async *_streamSse(url) {
1292
+ const headers = {
1293
+ ...this.headers,
1294
+ // includes Authorization and any custom headers
1295
+ Accept: "text/event-stream",
1296
+ "Cache-Control": "no-cache"
1297
+ };
1298
+ const response = await fetch(url, { headers });
1299
+ if (!response.ok || !response.body) {
1300
+ throw new Error(`SSE connection failed: ${response.status} ${response.statusText}`);
1301
+ }
1302
+ const reader = response.body.getReader();
1303
+ const decoder = new TextDecoder();
1304
+ let buffer = "";
1305
+ try {
1306
+ while (true) {
1307
+ const { done, value } = await reader.read();
1308
+ if (done) break;
1309
+ buffer += decoder.decode(value, { stream: true });
1310
+ let boundary;
1311
+ while ((boundary = buffer.indexOf("\n\n")) !== -1) {
1312
+ const block = buffer.slice(0, boundary);
1313
+ buffer = buffer.slice(boundary + 2);
1314
+ const event = this._parseSseBlock(block);
1315
+ if (event !== null) yield event;
1316
+ }
1317
+ }
1318
+ } finally {
1319
+ reader.releaseLock();
1320
+ }
1321
+ }
1322
+ /** Parse a single SSE event block into a {@link DakeraEvent}. */
1323
+ _parseSseBlock(block) {
1324
+ const dataLines = [];
1325
+ for (const line of block.split("\n")) {
1326
+ if (line.startsWith(":")) continue;
1327
+ if (line.startsWith("data:")) dataLines.push(line.slice(5).trimStart());
1328
+ }
1329
+ if (dataLines.length === 0) return null;
1330
+ try {
1331
+ return JSON.parse(dataLines.join("\n"));
1332
+ } catch {
1333
+ return null;
1334
+ }
1335
+ }
1336
+ /**
1337
+ * Low-level SSE streaming helper for the memory event stream.
1338
+ *
1339
+ * The memory event stream sets the SSE `event:` field to the event_type
1340
+ * and the `data:` field to the JSON payload. This helper merges the two
1341
+ * so callers receive a fully-populated {@link MemoryEvent}.
1342
+ */
1343
+ async *_streamSseMemory(url) {
1344
+ const headers = {
1345
+ ...this.headers,
1346
+ Accept: "text/event-stream",
1347
+ "Cache-Control": "no-cache"
1348
+ };
1349
+ const response = await fetch(url, { headers });
1350
+ if (!response.ok || !response.body) {
1351
+ throw new Error(`SSE connection failed: ${response.status} ${response.statusText}`);
1352
+ }
1353
+ const reader = response.body.getReader();
1354
+ const decoder = new TextDecoder();
1355
+ let buffer = "";
1356
+ try {
1357
+ while (true) {
1358
+ const { done, value } = await reader.read();
1359
+ if (done) break;
1360
+ buffer += decoder.decode(value, { stream: true });
1361
+ let boundary;
1362
+ while ((boundary = buffer.indexOf("\n\n")) !== -1) {
1363
+ const block = buffer.slice(0, boundary);
1364
+ buffer = buffer.slice(boundary + 2);
1365
+ const event = this._parseSseMemoryBlock(block);
1366
+ if (event !== null) yield event;
1367
+ }
1368
+ }
1369
+ } finally {
1370
+ reader.releaseLock();
1371
+ }
1372
+ }
1373
+ /** Parse a single SSE event block into a {@link MemoryEvent}. */
1374
+ _parseSseMemoryBlock(block) {
1375
+ let eventType;
1376
+ const dataLines = [];
1377
+ for (const line of block.split("\n")) {
1378
+ if (line.startsWith(":")) continue;
1379
+ if (line.startsWith("event:")) {
1380
+ eventType = line.slice(6).trim();
1381
+ } else if (line.startsWith("data:")) {
1382
+ dataLines.push(line.slice(5).trimStart());
1383
+ }
1384
+ }
1385
+ if (dataLines.length === 0) return null;
1386
+ try {
1387
+ const parsed = JSON.parse(dataLines.join("\n"));
1388
+ if (eventType && !parsed.event_type) {
1389
+ parsed.event_type = eventType;
1390
+ }
1391
+ return parsed;
1392
+ } catch {
1393
+ return null;
1394
+ }
1395
+ }
1202
1396
  };
1203
1397
 
1204
1398
  // src/types.ts
package/dist/index.mjs CHANGED
@@ -1018,6 +1018,28 @@ var DakeraClient = class {
1018
1018
  async deduplicate(request) {
1019
1019
  return this.request("POST", "/v1/knowledge/deduplicate", request);
1020
1020
  }
1021
+ /**
1022
+ * Build a cross-agent memory network graph (DASH-A).
1023
+ *
1024
+ * Calls `POST /v1/knowledge/network/cross-agent` and returns a graph
1025
+ * containing every agent's nodes and the cross-agent similarity edges that
1026
+ * connect them.
1027
+ *
1028
+ * Requires an Admin-scoped API key.
1029
+ *
1030
+ * @example
1031
+ * ```ts
1032
+ * const network = await client.crossAgentNetwork({ min_similarity: 0.5 });
1033
+ * console.log(`${network.stats.total_cross_edges} cross-agent edges`);
1034
+ * ```
1035
+ */
1036
+ async crossAgentNetwork(req) {
1037
+ return this.request(
1038
+ "POST",
1039
+ "/v1/knowledge/network/cross-agent",
1040
+ req ?? {}
1041
+ );
1042
+ }
1021
1043
  // ===========================================================================
1022
1044
  // Analytics Operations
1023
1045
  // ===========================================================================
@@ -1161,6 +1183,178 @@ var DakeraClient = class {
1161
1183
  async keyUsage(keyId) {
1162
1184
  return this.request("GET", `/v1/keys/${keyId}/usage`);
1163
1185
  }
1186
+ // ===========================================================================
1187
+ // SSE Streaming (CE-1)
1188
+ // ===========================================================================
1189
+ /**
1190
+ * Stream SSE events scoped to a namespace.
1191
+ *
1192
+ * Opens a long-lived connection to `GET /v1/namespaces/{namespace}/events`
1193
+ * and yields {@link DakeraEvent} objects as they arrive. The async
1194
+ * generator runs until the connection closes or the caller breaks the loop.
1195
+ *
1196
+ * Requires a Read-scoped API key.
1197
+ *
1198
+ * @example
1199
+ * ```ts
1200
+ * for await (const event of client.streamNamespaceEvents('my-ns')) {
1201
+ * if (event.type === 'vectors_mutated') {
1202
+ * console.log(`${event.count} vectors ${event.op} in ${event.namespace}`);
1203
+ * }
1204
+ * }
1205
+ * ```
1206
+ */
1207
+ async *streamNamespaceEvents(namespace) {
1208
+ const url = `${this.baseUrl}/v1/namespaces/${encodeURIComponent(namespace)}/events`;
1209
+ yield* this._streamSse(url);
1210
+ }
1211
+ /**
1212
+ * Stream all system events from the global event bus.
1213
+ *
1214
+ * Opens a long-lived connection to `GET /ops/events` and yields
1215
+ * {@link DakeraEvent} objects as they arrive.
1216
+ *
1217
+ * Requires an Admin-scoped API key.
1218
+ *
1219
+ * @example
1220
+ * ```ts
1221
+ * for await (const event of client.streamGlobalEvents()) {
1222
+ * console.log(event.type, event);
1223
+ * }
1224
+ * ```
1225
+ */
1226
+ async *streamGlobalEvents() {
1227
+ const url = `${this.baseUrl}/ops/events`;
1228
+ yield* this._streamSse(url);
1229
+ }
1230
+ /**
1231
+ * Stream memory lifecycle events for all agents (DASH-B).
1232
+ *
1233
+ * Opens a long-lived connection to `GET /v1/events/stream` and yields
1234
+ * {@link MemoryEvent} objects as they arrive. Each SSE frame uses the
1235
+ * `event:` field for the event_type and a JSON `data:` payload.
1236
+ *
1237
+ * Requires a Read-scoped API key.
1238
+ *
1239
+ * @example
1240
+ * ```ts
1241
+ * for await (const ev of client.streamMemoryEvents()) {
1242
+ * if (ev.event_type === 'stored') {
1243
+ * console.log(`Memory stored for agent ${ev.agent_id}: ${ev.content}`);
1244
+ * }
1245
+ * }
1246
+ * ```
1247
+ */
1248
+ async *streamMemoryEvents() {
1249
+ const url = `${this.baseUrl}/v1/events/stream`;
1250
+ yield* this._streamSseMemory(url);
1251
+ }
1252
+ /** Low-level SSE streaming helper — parses the SSE wire format. */
1253
+ async *_streamSse(url) {
1254
+ const headers = {
1255
+ ...this.headers,
1256
+ // includes Authorization and any custom headers
1257
+ Accept: "text/event-stream",
1258
+ "Cache-Control": "no-cache"
1259
+ };
1260
+ const response = await fetch(url, { headers });
1261
+ if (!response.ok || !response.body) {
1262
+ throw new Error(`SSE connection failed: ${response.status} ${response.statusText}`);
1263
+ }
1264
+ const reader = response.body.getReader();
1265
+ const decoder = new TextDecoder();
1266
+ let buffer = "";
1267
+ try {
1268
+ while (true) {
1269
+ const { done, value } = await reader.read();
1270
+ if (done) break;
1271
+ buffer += decoder.decode(value, { stream: true });
1272
+ let boundary;
1273
+ while ((boundary = buffer.indexOf("\n\n")) !== -1) {
1274
+ const block = buffer.slice(0, boundary);
1275
+ buffer = buffer.slice(boundary + 2);
1276
+ const event = this._parseSseBlock(block);
1277
+ if (event !== null) yield event;
1278
+ }
1279
+ }
1280
+ } finally {
1281
+ reader.releaseLock();
1282
+ }
1283
+ }
1284
+ /** Parse a single SSE event block into a {@link DakeraEvent}. */
1285
+ _parseSseBlock(block) {
1286
+ const dataLines = [];
1287
+ for (const line of block.split("\n")) {
1288
+ if (line.startsWith(":")) continue;
1289
+ if (line.startsWith("data:")) dataLines.push(line.slice(5).trimStart());
1290
+ }
1291
+ if (dataLines.length === 0) return null;
1292
+ try {
1293
+ return JSON.parse(dataLines.join("\n"));
1294
+ } catch {
1295
+ return null;
1296
+ }
1297
+ }
1298
+ /**
1299
+ * Low-level SSE streaming helper for the memory event stream.
1300
+ *
1301
+ * The memory event stream sets the SSE `event:` field to the event_type
1302
+ * and the `data:` field to the JSON payload. This helper merges the two
1303
+ * so callers receive a fully-populated {@link MemoryEvent}.
1304
+ */
1305
+ async *_streamSseMemory(url) {
1306
+ const headers = {
1307
+ ...this.headers,
1308
+ Accept: "text/event-stream",
1309
+ "Cache-Control": "no-cache"
1310
+ };
1311
+ const response = await fetch(url, { headers });
1312
+ if (!response.ok || !response.body) {
1313
+ throw new Error(`SSE connection failed: ${response.status} ${response.statusText}`);
1314
+ }
1315
+ const reader = response.body.getReader();
1316
+ const decoder = new TextDecoder();
1317
+ let buffer = "";
1318
+ try {
1319
+ while (true) {
1320
+ const { done, value } = await reader.read();
1321
+ if (done) break;
1322
+ buffer += decoder.decode(value, { stream: true });
1323
+ let boundary;
1324
+ while ((boundary = buffer.indexOf("\n\n")) !== -1) {
1325
+ const block = buffer.slice(0, boundary);
1326
+ buffer = buffer.slice(boundary + 2);
1327
+ const event = this._parseSseMemoryBlock(block);
1328
+ if (event !== null) yield event;
1329
+ }
1330
+ }
1331
+ } finally {
1332
+ reader.releaseLock();
1333
+ }
1334
+ }
1335
+ /** Parse a single SSE event block into a {@link MemoryEvent}. */
1336
+ _parseSseMemoryBlock(block) {
1337
+ let eventType;
1338
+ const dataLines = [];
1339
+ for (const line of block.split("\n")) {
1340
+ if (line.startsWith(":")) continue;
1341
+ if (line.startsWith("event:")) {
1342
+ eventType = line.slice(6).trim();
1343
+ } else if (line.startsWith("data:")) {
1344
+ dataLines.push(line.slice(5).trimStart());
1345
+ }
1346
+ }
1347
+ if (dataLines.length === 0) return null;
1348
+ try {
1349
+ const parsed = JSON.parse(dataLines.join("\n"));
1350
+ if (eventType && !parsed.event_type) {
1351
+ parsed.event_type = eventType;
1352
+ }
1353
+ return parsed;
1354
+ } catch {
1355
+ return null;
1356
+ }
1357
+ }
1164
1358
  };
1165
1359
 
1166
1360
  // src/types.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dakera-ai/dakera",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "description": "TypeScript/JavaScript SDK for Dakera AI memory platform",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",