@dakera-ai/dakera 0.4.0 → 0.6.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 +162 -4
- package/dist/index.d.ts +162 -4
- package/dist/index.js +117 -0
- package/dist/index.mjs +117 -0
- package/package.json +1 -1
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:
|
|
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:
|
|
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:
|
|
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 */
|
|
@@ -878,6 +903,83 @@ interface StreamLaggedEvent {
|
|
|
878
903
|
}
|
|
879
904
|
/** Union of all Dakera SSE event types. */
|
|
880
905
|
type DakeraEvent = NamespaceCreatedEvent | NamespaceDeletedEvent | OperationProgressEvent | JobProgressEvent | VectorsMutatedEvent | StreamLaggedEvent;
|
|
906
|
+
/**
|
|
907
|
+
* A memory lifecycle event emitted on the agent memory SSE stream.
|
|
908
|
+
*
|
|
909
|
+
* event_type values:
|
|
910
|
+
* stored | recalled | forgotten | consolidated |
|
|
911
|
+
* importance_updated | session_started | session_ended
|
|
912
|
+
*/
|
|
913
|
+
interface MemoryEvent {
|
|
914
|
+
/** Memory lifecycle event type */
|
|
915
|
+
event_type: string;
|
|
916
|
+
/** Agent that owns the memory */
|
|
917
|
+
agent_id: string;
|
|
918
|
+
/** Unix milliseconds */
|
|
919
|
+
timestamp: number;
|
|
920
|
+
/** Memory ID (present for most event types) */
|
|
921
|
+
memory_id?: string;
|
|
922
|
+
/** Memory content snapshot */
|
|
923
|
+
content?: string;
|
|
924
|
+
/** Importance score at the time of the event */
|
|
925
|
+
importance?: number;
|
|
926
|
+
/** Tags associated with the memory */
|
|
927
|
+
tags?: string[];
|
|
928
|
+
/** Session ID (present for session_started / session_ended events) */
|
|
929
|
+
session_id?: string;
|
|
930
|
+
}
|
|
931
|
+
/** Summary info for one agent in the cross-agent network */
|
|
932
|
+
interface AgentNetworkInfo {
|
|
933
|
+
agent_id: string;
|
|
934
|
+
memory_count: number;
|
|
935
|
+
avg_importance: number;
|
|
936
|
+
}
|
|
937
|
+
/** A node in the cross-agent memory network graph */
|
|
938
|
+
interface AgentNetworkNode {
|
|
939
|
+
id: string;
|
|
940
|
+
agent_id: string;
|
|
941
|
+
content: string;
|
|
942
|
+
importance: number;
|
|
943
|
+
tags: string[];
|
|
944
|
+
memory_type: string;
|
|
945
|
+
/** Unix milliseconds */
|
|
946
|
+
created_at: number;
|
|
947
|
+
}
|
|
948
|
+
/** A cross-agent similarity edge */
|
|
949
|
+
interface AgentNetworkEdge {
|
|
950
|
+
source: string;
|
|
951
|
+
target: string;
|
|
952
|
+
source_agent: string;
|
|
953
|
+
target_agent: string;
|
|
954
|
+
similarity: number;
|
|
955
|
+
}
|
|
956
|
+
/** Aggregate statistics for the cross-agent network */
|
|
957
|
+
interface AgentNetworkStats {
|
|
958
|
+
total_agents: number;
|
|
959
|
+
total_nodes: number;
|
|
960
|
+
total_cross_edges: number;
|
|
961
|
+
density: number;
|
|
962
|
+
}
|
|
963
|
+
/** Response from the cross-agent network endpoint */
|
|
964
|
+
interface CrossAgentNetworkResponse {
|
|
965
|
+
agents: AgentNetworkInfo[];
|
|
966
|
+
nodes: AgentNetworkNode[];
|
|
967
|
+
edges: AgentNetworkEdge[];
|
|
968
|
+
stats: AgentNetworkStats;
|
|
969
|
+
}
|
|
970
|
+
/** Request body for POST /v1/knowledge/network/cross-agent */
|
|
971
|
+
interface CrossAgentNetworkRequest {
|
|
972
|
+
/** Agent IDs to include — undefined means all agents */
|
|
973
|
+
agent_ids?: string[];
|
|
974
|
+
/** Minimum similarity threshold for edges (default 0.3) */
|
|
975
|
+
min_similarity?: number;
|
|
976
|
+
/** Maximum nodes to include per agent (default 50) */
|
|
977
|
+
max_nodes_per_agent?: number;
|
|
978
|
+
/** Minimum importance for a node to be included (default 0.0) */
|
|
979
|
+
min_importance?: number;
|
|
980
|
+
/** Maximum cross-agent edges to return (default 200) */
|
|
981
|
+
max_cross_edges?: number;
|
|
982
|
+
}
|
|
881
983
|
/** Cluster status response */
|
|
882
984
|
interface ClusterStatus {
|
|
883
985
|
status: string;
|
|
@@ -1133,6 +1235,17 @@ declare class DakeraClient {
|
|
|
1133
1235
|
indexType?: string;
|
|
1134
1236
|
metadata?: Record<string, unknown>;
|
|
1135
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>;
|
|
1136
1249
|
/**
|
|
1137
1250
|
* Delete a namespace.
|
|
1138
1251
|
*
|
|
@@ -1490,6 +1603,22 @@ declare class DakeraClient {
|
|
|
1490
1603
|
summarize(request: SummarizeRequest): Promise<SummarizeResponse>;
|
|
1491
1604
|
/** Deduplicate memories */
|
|
1492
1605
|
deduplicate(request: DeduplicateRequest): Promise<DeduplicateResponse>;
|
|
1606
|
+
/**
|
|
1607
|
+
* Build a cross-agent memory network graph (DASH-A).
|
|
1608
|
+
*
|
|
1609
|
+
* Calls `POST /v1/knowledge/network/cross-agent` and returns a graph
|
|
1610
|
+
* containing every agent's nodes and the cross-agent similarity edges that
|
|
1611
|
+
* connect them.
|
|
1612
|
+
*
|
|
1613
|
+
* Requires an Admin-scoped API key.
|
|
1614
|
+
*
|
|
1615
|
+
* @example
|
|
1616
|
+
* ```ts
|
|
1617
|
+
* const network = await client.crossAgentNetwork({ min_similarity: 0.5 });
|
|
1618
|
+
* console.log(`${network.stats.total_cross_edges} cross-agent edges`);
|
|
1619
|
+
* ```
|
|
1620
|
+
*/
|
|
1621
|
+
crossAgentNetwork(req?: CrossAgentNetworkRequest): Promise<CrossAgentNetworkResponse>;
|
|
1493
1622
|
/** Get analytics overview */
|
|
1494
1623
|
analyticsOverview(options?: AnalyticsOptions): Promise<AnalyticsOverview>;
|
|
1495
1624
|
/** Get latency analytics */
|
|
@@ -1596,10 +1725,39 @@ declare class DakeraClient {
|
|
|
1596
1725
|
* ```
|
|
1597
1726
|
*/
|
|
1598
1727
|
streamGlobalEvents(): AsyncGenerator<DakeraEvent>;
|
|
1728
|
+
/**
|
|
1729
|
+
* Stream memory lifecycle events for all agents (DASH-B).
|
|
1730
|
+
*
|
|
1731
|
+
* Opens a long-lived connection to `GET /v1/events/stream` and yields
|
|
1732
|
+
* {@link MemoryEvent} objects as they arrive. Each SSE frame uses the
|
|
1733
|
+
* `event:` field for the event_type and a JSON `data:` payload.
|
|
1734
|
+
*
|
|
1735
|
+
* Requires a Read-scoped API key.
|
|
1736
|
+
*
|
|
1737
|
+
* @example
|
|
1738
|
+
* ```ts
|
|
1739
|
+
* for await (const ev of client.streamMemoryEvents()) {
|
|
1740
|
+
* if (ev.event_type === 'stored') {
|
|
1741
|
+
* console.log(`Memory stored for agent ${ev.agent_id}: ${ev.content}`);
|
|
1742
|
+
* }
|
|
1743
|
+
* }
|
|
1744
|
+
* ```
|
|
1745
|
+
*/
|
|
1746
|
+
streamMemoryEvents(): AsyncGenerator<MemoryEvent>;
|
|
1599
1747
|
/** Low-level SSE streaming helper — parses the SSE wire format. */
|
|
1600
1748
|
private _streamSse;
|
|
1601
1749
|
/** Parse a single SSE event block into a {@link DakeraEvent}. */
|
|
1602
1750
|
private _parseSseBlock;
|
|
1751
|
+
/**
|
|
1752
|
+
* Low-level SSE streaming helper for the memory event stream.
|
|
1753
|
+
*
|
|
1754
|
+
* The memory event stream sets the SSE `event:` field to the event_type
|
|
1755
|
+
* and the `data:` field to the JSON payload. This helper merges the two
|
|
1756
|
+
* so callers receive a fully-populated {@link MemoryEvent}.
|
|
1757
|
+
*/
|
|
1758
|
+
private _streamSseMemory;
|
|
1759
|
+
/** Parse a single SSE event block into a {@link MemoryEvent}. */
|
|
1760
|
+
private _parseSseMemoryBlock;
|
|
1603
1761
|
}
|
|
1604
1762
|
|
|
1605
1763
|
/**
|
|
@@ -1641,4 +1799,4 @@ declare class TimeoutError extends DakeraError {
|
|
|
1641
1799
|
constructor(message: string);
|
|
1642
1800
|
}
|
|
1643
1801
|
|
|
1644
|
-
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 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 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 };
|
|
1802
|
+
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, 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, 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:
|
|
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:
|
|
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:
|
|
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 */
|
|
@@ -878,6 +903,83 @@ interface StreamLaggedEvent {
|
|
|
878
903
|
}
|
|
879
904
|
/** Union of all Dakera SSE event types. */
|
|
880
905
|
type DakeraEvent = NamespaceCreatedEvent | NamespaceDeletedEvent | OperationProgressEvent | JobProgressEvent | VectorsMutatedEvent | StreamLaggedEvent;
|
|
906
|
+
/**
|
|
907
|
+
* A memory lifecycle event emitted on the agent memory SSE stream.
|
|
908
|
+
*
|
|
909
|
+
* event_type values:
|
|
910
|
+
* stored | recalled | forgotten | consolidated |
|
|
911
|
+
* importance_updated | session_started | session_ended
|
|
912
|
+
*/
|
|
913
|
+
interface MemoryEvent {
|
|
914
|
+
/** Memory lifecycle event type */
|
|
915
|
+
event_type: string;
|
|
916
|
+
/** Agent that owns the memory */
|
|
917
|
+
agent_id: string;
|
|
918
|
+
/** Unix milliseconds */
|
|
919
|
+
timestamp: number;
|
|
920
|
+
/** Memory ID (present for most event types) */
|
|
921
|
+
memory_id?: string;
|
|
922
|
+
/** Memory content snapshot */
|
|
923
|
+
content?: string;
|
|
924
|
+
/** Importance score at the time of the event */
|
|
925
|
+
importance?: number;
|
|
926
|
+
/** Tags associated with the memory */
|
|
927
|
+
tags?: string[];
|
|
928
|
+
/** Session ID (present for session_started / session_ended events) */
|
|
929
|
+
session_id?: string;
|
|
930
|
+
}
|
|
931
|
+
/** Summary info for one agent in the cross-agent network */
|
|
932
|
+
interface AgentNetworkInfo {
|
|
933
|
+
agent_id: string;
|
|
934
|
+
memory_count: number;
|
|
935
|
+
avg_importance: number;
|
|
936
|
+
}
|
|
937
|
+
/** A node in the cross-agent memory network graph */
|
|
938
|
+
interface AgentNetworkNode {
|
|
939
|
+
id: string;
|
|
940
|
+
agent_id: string;
|
|
941
|
+
content: string;
|
|
942
|
+
importance: number;
|
|
943
|
+
tags: string[];
|
|
944
|
+
memory_type: string;
|
|
945
|
+
/** Unix milliseconds */
|
|
946
|
+
created_at: number;
|
|
947
|
+
}
|
|
948
|
+
/** A cross-agent similarity edge */
|
|
949
|
+
interface AgentNetworkEdge {
|
|
950
|
+
source: string;
|
|
951
|
+
target: string;
|
|
952
|
+
source_agent: string;
|
|
953
|
+
target_agent: string;
|
|
954
|
+
similarity: number;
|
|
955
|
+
}
|
|
956
|
+
/** Aggregate statistics for the cross-agent network */
|
|
957
|
+
interface AgentNetworkStats {
|
|
958
|
+
total_agents: number;
|
|
959
|
+
total_nodes: number;
|
|
960
|
+
total_cross_edges: number;
|
|
961
|
+
density: number;
|
|
962
|
+
}
|
|
963
|
+
/** Response from the cross-agent network endpoint */
|
|
964
|
+
interface CrossAgentNetworkResponse {
|
|
965
|
+
agents: AgentNetworkInfo[];
|
|
966
|
+
nodes: AgentNetworkNode[];
|
|
967
|
+
edges: AgentNetworkEdge[];
|
|
968
|
+
stats: AgentNetworkStats;
|
|
969
|
+
}
|
|
970
|
+
/** Request body for POST /v1/knowledge/network/cross-agent */
|
|
971
|
+
interface CrossAgentNetworkRequest {
|
|
972
|
+
/** Agent IDs to include — undefined means all agents */
|
|
973
|
+
agent_ids?: string[];
|
|
974
|
+
/** Minimum similarity threshold for edges (default 0.3) */
|
|
975
|
+
min_similarity?: number;
|
|
976
|
+
/** Maximum nodes to include per agent (default 50) */
|
|
977
|
+
max_nodes_per_agent?: number;
|
|
978
|
+
/** Minimum importance for a node to be included (default 0.0) */
|
|
979
|
+
min_importance?: number;
|
|
980
|
+
/** Maximum cross-agent edges to return (default 200) */
|
|
981
|
+
max_cross_edges?: number;
|
|
982
|
+
}
|
|
881
983
|
/** Cluster status response */
|
|
882
984
|
interface ClusterStatus {
|
|
883
985
|
status: string;
|
|
@@ -1133,6 +1235,17 @@ declare class DakeraClient {
|
|
|
1133
1235
|
indexType?: string;
|
|
1134
1236
|
metadata?: Record<string, unknown>;
|
|
1135
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>;
|
|
1136
1249
|
/**
|
|
1137
1250
|
* Delete a namespace.
|
|
1138
1251
|
*
|
|
@@ -1490,6 +1603,22 @@ declare class DakeraClient {
|
|
|
1490
1603
|
summarize(request: SummarizeRequest): Promise<SummarizeResponse>;
|
|
1491
1604
|
/** Deduplicate memories */
|
|
1492
1605
|
deduplicate(request: DeduplicateRequest): Promise<DeduplicateResponse>;
|
|
1606
|
+
/**
|
|
1607
|
+
* Build a cross-agent memory network graph (DASH-A).
|
|
1608
|
+
*
|
|
1609
|
+
* Calls `POST /v1/knowledge/network/cross-agent` and returns a graph
|
|
1610
|
+
* containing every agent's nodes and the cross-agent similarity edges that
|
|
1611
|
+
* connect them.
|
|
1612
|
+
*
|
|
1613
|
+
* Requires an Admin-scoped API key.
|
|
1614
|
+
*
|
|
1615
|
+
* @example
|
|
1616
|
+
* ```ts
|
|
1617
|
+
* const network = await client.crossAgentNetwork({ min_similarity: 0.5 });
|
|
1618
|
+
* console.log(`${network.stats.total_cross_edges} cross-agent edges`);
|
|
1619
|
+
* ```
|
|
1620
|
+
*/
|
|
1621
|
+
crossAgentNetwork(req?: CrossAgentNetworkRequest): Promise<CrossAgentNetworkResponse>;
|
|
1493
1622
|
/** Get analytics overview */
|
|
1494
1623
|
analyticsOverview(options?: AnalyticsOptions): Promise<AnalyticsOverview>;
|
|
1495
1624
|
/** Get latency analytics */
|
|
@@ -1596,10 +1725,39 @@ declare class DakeraClient {
|
|
|
1596
1725
|
* ```
|
|
1597
1726
|
*/
|
|
1598
1727
|
streamGlobalEvents(): AsyncGenerator<DakeraEvent>;
|
|
1728
|
+
/**
|
|
1729
|
+
* Stream memory lifecycle events for all agents (DASH-B).
|
|
1730
|
+
*
|
|
1731
|
+
* Opens a long-lived connection to `GET /v1/events/stream` and yields
|
|
1732
|
+
* {@link MemoryEvent} objects as they arrive. Each SSE frame uses the
|
|
1733
|
+
* `event:` field for the event_type and a JSON `data:` payload.
|
|
1734
|
+
*
|
|
1735
|
+
* Requires a Read-scoped API key.
|
|
1736
|
+
*
|
|
1737
|
+
* @example
|
|
1738
|
+
* ```ts
|
|
1739
|
+
* for await (const ev of client.streamMemoryEvents()) {
|
|
1740
|
+
* if (ev.event_type === 'stored') {
|
|
1741
|
+
* console.log(`Memory stored for agent ${ev.agent_id}: ${ev.content}`);
|
|
1742
|
+
* }
|
|
1743
|
+
* }
|
|
1744
|
+
* ```
|
|
1745
|
+
*/
|
|
1746
|
+
streamMemoryEvents(): AsyncGenerator<MemoryEvent>;
|
|
1599
1747
|
/** Low-level SSE streaming helper — parses the SSE wire format. */
|
|
1600
1748
|
private _streamSse;
|
|
1601
1749
|
/** Parse a single SSE event block into a {@link DakeraEvent}. */
|
|
1602
1750
|
private _parseSseBlock;
|
|
1751
|
+
/**
|
|
1752
|
+
* Low-level SSE streaming helper for the memory event stream.
|
|
1753
|
+
*
|
|
1754
|
+
* The memory event stream sets the SSE `event:` field to the event_type
|
|
1755
|
+
* and the `data:` field to the JSON payload. This helper merges the two
|
|
1756
|
+
* so callers receive a fully-populated {@link MemoryEvent}.
|
|
1757
|
+
*/
|
|
1758
|
+
private _streamSseMemory;
|
|
1759
|
+
/** Parse a single SSE event block into a {@link MemoryEvent}. */
|
|
1760
|
+
private _parseSseMemoryBlock;
|
|
1603
1761
|
}
|
|
1604
1762
|
|
|
1605
1763
|
/**
|
|
@@ -1641,4 +1799,4 @@ declare class TimeoutError extends DakeraError {
|
|
|
1641
1799
|
constructor(message: string);
|
|
1642
1800
|
}
|
|
1643
1801
|
|
|
1644
|
-
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 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 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 };
|
|
1802
|
+
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, 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, 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
|
@@ -473,6 +473,19 @@ var DakeraClient = class {
|
|
|
473
473
|
if (options.metadata) body.metadata = options.metadata;
|
|
474
474
|
return this.request("POST", "/v1/namespaces", body);
|
|
475
475
|
}
|
|
476
|
+
/**
|
|
477
|
+
* Create or update a namespace configuration (upsert semantics).
|
|
478
|
+
*
|
|
479
|
+
* Creates the namespace if it does not exist, or updates its configuration
|
|
480
|
+
* if it already exists. Requires Write scope.
|
|
481
|
+
*
|
|
482
|
+
* @param namespace - Namespace name
|
|
483
|
+
* @param request - dimension and optional distance metric
|
|
484
|
+
* @returns ConfigureNamespaceResponse with ``created: true`` if newly created
|
|
485
|
+
*/
|
|
486
|
+
async configureNamespace(namespace, request) {
|
|
487
|
+
return this.request("PUT", `/v1/namespaces/${namespace}`, request);
|
|
488
|
+
}
|
|
476
489
|
/**
|
|
477
490
|
* Delete a namespace.
|
|
478
491
|
*
|
|
@@ -1056,6 +1069,28 @@ var DakeraClient = class {
|
|
|
1056
1069
|
async deduplicate(request) {
|
|
1057
1070
|
return this.request("POST", "/v1/knowledge/deduplicate", request);
|
|
1058
1071
|
}
|
|
1072
|
+
/**
|
|
1073
|
+
* Build a cross-agent memory network graph (DASH-A).
|
|
1074
|
+
*
|
|
1075
|
+
* Calls `POST /v1/knowledge/network/cross-agent` and returns a graph
|
|
1076
|
+
* containing every agent's nodes and the cross-agent similarity edges that
|
|
1077
|
+
* connect them.
|
|
1078
|
+
*
|
|
1079
|
+
* Requires an Admin-scoped API key.
|
|
1080
|
+
*
|
|
1081
|
+
* @example
|
|
1082
|
+
* ```ts
|
|
1083
|
+
* const network = await client.crossAgentNetwork({ min_similarity: 0.5 });
|
|
1084
|
+
* console.log(`${network.stats.total_cross_edges} cross-agent edges`);
|
|
1085
|
+
* ```
|
|
1086
|
+
*/
|
|
1087
|
+
async crossAgentNetwork(req) {
|
|
1088
|
+
return this.request(
|
|
1089
|
+
"POST",
|
|
1090
|
+
"/v1/knowledge/network/cross-agent",
|
|
1091
|
+
req ?? {}
|
|
1092
|
+
);
|
|
1093
|
+
}
|
|
1059
1094
|
// ===========================================================================
|
|
1060
1095
|
// Analytics Operations
|
|
1061
1096
|
// ===========================================================================
|
|
@@ -1243,6 +1278,28 @@ var DakeraClient = class {
|
|
|
1243
1278
|
const url = `${this.baseUrl}/ops/events`;
|
|
1244
1279
|
yield* this._streamSse(url);
|
|
1245
1280
|
}
|
|
1281
|
+
/**
|
|
1282
|
+
* Stream memory lifecycle events for all agents (DASH-B).
|
|
1283
|
+
*
|
|
1284
|
+
* Opens a long-lived connection to `GET /v1/events/stream` and yields
|
|
1285
|
+
* {@link MemoryEvent} objects as they arrive. Each SSE frame uses the
|
|
1286
|
+
* `event:` field for the event_type and a JSON `data:` payload.
|
|
1287
|
+
*
|
|
1288
|
+
* Requires a Read-scoped API key.
|
|
1289
|
+
*
|
|
1290
|
+
* @example
|
|
1291
|
+
* ```ts
|
|
1292
|
+
* for await (const ev of client.streamMemoryEvents()) {
|
|
1293
|
+
* if (ev.event_type === 'stored') {
|
|
1294
|
+
* console.log(`Memory stored for agent ${ev.agent_id}: ${ev.content}`);
|
|
1295
|
+
* }
|
|
1296
|
+
* }
|
|
1297
|
+
* ```
|
|
1298
|
+
*/
|
|
1299
|
+
async *streamMemoryEvents() {
|
|
1300
|
+
const url = `${this.baseUrl}/v1/events/stream`;
|
|
1301
|
+
yield* this._streamSseMemory(url);
|
|
1302
|
+
}
|
|
1246
1303
|
/** Low-level SSE streaming helper — parses the SSE wire format. */
|
|
1247
1304
|
async *_streamSse(url) {
|
|
1248
1305
|
const headers = {
|
|
@@ -1289,6 +1346,66 @@ var DakeraClient = class {
|
|
|
1289
1346
|
return null;
|
|
1290
1347
|
}
|
|
1291
1348
|
}
|
|
1349
|
+
/**
|
|
1350
|
+
* Low-level SSE streaming helper for the memory event stream.
|
|
1351
|
+
*
|
|
1352
|
+
* The memory event stream sets the SSE `event:` field to the event_type
|
|
1353
|
+
* and the `data:` field to the JSON payload. This helper merges the two
|
|
1354
|
+
* so callers receive a fully-populated {@link MemoryEvent}.
|
|
1355
|
+
*/
|
|
1356
|
+
async *_streamSseMemory(url) {
|
|
1357
|
+
const headers = {
|
|
1358
|
+
...this.headers,
|
|
1359
|
+
Accept: "text/event-stream",
|
|
1360
|
+
"Cache-Control": "no-cache"
|
|
1361
|
+
};
|
|
1362
|
+
const response = await fetch(url, { headers });
|
|
1363
|
+
if (!response.ok || !response.body) {
|
|
1364
|
+
throw new Error(`SSE connection failed: ${response.status} ${response.statusText}`);
|
|
1365
|
+
}
|
|
1366
|
+
const reader = response.body.getReader();
|
|
1367
|
+
const decoder = new TextDecoder();
|
|
1368
|
+
let buffer = "";
|
|
1369
|
+
try {
|
|
1370
|
+
while (true) {
|
|
1371
|
+
const { done, value } = await reader.read();
|
|
1372
|
+
if (done) break;
|
|
1373
|
+
buffer += decoder.decode(value, { stream: true });
|
|
1374
|
+
let boundary;
|
|
1375
|
+
while ((boundary = buffer.indexOf("\n\n")) !== -1) {
|
|
1376
|
+
const block = buffer.slice(0, boundary);
|
|
1377
|
+
buffer = buffer.slice(boundary + 2);
|
|
1378
|
+
const event = this._parseSseMemoryBlock(block);
|
|
1379
|
+
if (event !== null) yield event;
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
} finally {
|
|
1383
|
+
reader.releaseLock();
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
/** Parse a single SSE event block into a {@link MemoryEvent}. */
|
|
1387
|
+
_parseSseMemoryBlock(block) {
|
|
1388
|
+
let eventType;
|
|
1389
|
+
const dataLines = [];
|
|
1390
|
+
for (const line of block.split("\n")) {
|
|
1391
|
+
if (line.startsWith(":")) continue;
|
|
1392
|
+
if (line.startsWith("event:")) {
|
|
1393
|
+
eventType = line.slice(6).trim();
|
|
1394
|
+
} else if (line.startsWith("data:")) {
|
|
1395
|
+
dataLines.push(line.slice(5).trimStart());
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1398
|
+
if (dataLines.length === 0) return null;
|
|
1399
|
+
try {
|
|
1400
|
+
const parsed = JSON.parse(dataLines.join("\n"));
|
|
1401
|
+
if (eventType && !parsed.event_type) {
|
|
1402
|
+
parsed.event_type = eventType;
|
|
1403
|
+
}
|
|
1404
|
+
return parsed;
|
|
1405
|
+
} catch {
|
|
1406
|
+
return null;
|
|
1407
|
+
}
|
|
1408
|
+
}
|
|
1292
1409
|
};
|
|
1293
1410
|
|
|
1294
1411
|
// src/types.ts
|
package/dist/index.mjs
CHANGED
|
@@ -435,6 +435,19 @@ var DakeraClient = class {
|
|
|
435
435
|
if (options.metadata) body.metadata = options.metadata;
|
|
436
436
|
return this.request("POST", "/v1/namespaces", body);
|
|
437
437
|
}
|
|
438
|
+
/**
|
|
439
|
+
* Create or update a namespace configuration (upsert semantics).
|
|
440
|
+
*
|
|
441
|
+
* Creates the namespace if it does not exist, or updates its configuration
|
|
442
|
+
* if it already exists. Requires Write scope.
|
|
443
|
+
*
|
|
444
|
+
* @param namespace - Namespace name
|
|
445
|
+
* @param request - dimension and optional distance metric
|
|
446
|
+
* @returns ConfigureNamespaceResponse with ``created: true`` if newly created
|
|
447
|
+
*/
|
|
448
|
+
async configureNamespace(namespace, request) {
|
|
449
|
+
return this.request("PUT", `/v1/namespaces/${namespace}`, request);
|
|
450
|
+
}
|
|
438
451
|
/**
|
|
439
452
|
* Delete a namespace.
|
|
440
453
|
*
|
|
@@ -1018,6 +1031,28 @@ var DakeraClient = class {
|
|
|
1018
1031
|
async deduplicate(request) {
|
|
1019
1032
|
return this.request("POST", "/v1/knowledge/deduplicate", request);
|
|
1020
1033
|
}
|
|
1034
|
+
/**
|
|
1035
|
+
* Build a cross-agent memory network graph (DASH-A).
|
|
1036
|
+
*
|
|
1037
|
+
* Calls `POST /v1/knowledge/network/cross-agent` and returns a graph
|
|
1038
|
+
* containing every agent's nodes and the cross-agent similarity edges that
|
|
1039
|
+
* connect them.
|
|
1040
|
+
*
|
|
1041
|
+
* Requires an Admin-scoped API key.
|
|
1042
|
+
*
|
|
1043
|
+
* @example
|
|
1044
|
+
* ```ts
|
|
1045
|
+
* const network = await client.crossAgentNetwork({ min_similarity: 0.5 });
|
|
1046
|
+
* console.log(`${network.stats.total_cross_edges} cross-agent edges`);
|
|
1047
|
+
* ```
|
|
1048
|
+
*/
|
|
1049
|
+
async crossAgentNetwork(req) {
|
|
1050
|
+
return this.request(
|
|
1051
|
+
"POST",
|
|
1052
|
+
"/v1/knowledge/network/cross-agent",
|
|
1053
|
+
req ?? {}
|
|
1054
|
+
);
|
|
1055
|
+
}
|
|
1021
1056
|
// ===========================================================================
|
|
1022
1057
|
// Analytics Operations
|
|
1023
1058
|
// ===========================================================================
|
|
@@ -1205,6 +1240,28 @@ var DakeraClient = class {
|
|
|
1205
1240
|
const url = `${this.baseUrl}/ops/events`;
|
|
1206
1241
|
yield* this._streamSse(url);
|
|
1207
1242
|
}
|
|
1243
|
+
/**
|
|
1244
|
+
* Stream memory lifecycle events for all agents (DASH-B).
|
|
1245
|
+
*
|
|
1246
|
+
* Opens a long-lived connection to `GET /v1/events/stream` and yields
|
|
1247
|
+
* {@link MemoryEvent} objects as they arrive. Each SSE frame uses the
|
|
1248
|
+
* `event:` field for the event_type and a JSON `data:` payload.
|
|
1249
|
+
*
|
|
1250
|
+
* Requires a Read-scoped API key.
|
|
1251
|
+
*
|
|
1252
|
+
* @example
|
|
1253
|
+
* ```ts
|
|
1254
|
+
* for await (const ev of client.streamMemoryEvents()) {
|
|
1255
|
+
* if (ev.event_type === 'stored') {
|
|
1256
|
+
* console.log(`Memory stored for agent ${ev.agent_id}: ${ev.content}`);
|
|
1257
|
+
* }
|
|
1258
|
+
* }
|
|
1259
|
+
* ```
|
|
1260
|
+
*/
|
|
1261
|
+
async *streamMemoryEvents() {
|
|
1262
|
+
const url = `${this.baseUrl}/v1/events/stream`;
|
|
1263
|
+
yield* this._streamSseMemory(url);
|
|
1264
|
+
}
|
|
1208
1265
|
/** Low-level SSE streaming helper — parses the SSE wire format. */
|
|
1209
1266
|
async *_streamSse(url) {
|
|
1210
1267
|
const headers = {
|
|
@@ -1251,6 +1308,66 @@ var DakeraClient = class {
|
|
|
1251
1308
|
return null;
|
|
1252
1309
|
}
|
|
1253
1310
|
}
|
|
1311
|
+
/**
|
|
1312
|
+
* Low-level SSE streaming helper for the memory event stream.
|
|
1313
|
+
*
|
|
1314
|
+
* The memory event stream sets the SSE `event:` field to the event_type
|
|
1315
|
+
* and the `data:` field to the JSON payload. This helper merges the two
|
|
1316
|
+
* so callers receive a fully-populated {@link MemoryEvent}.
|
|
1317
|
+
*/
|
|
1318
|
+
async *_streamSseMemory(url) {
|
|
1319
|
+
const headers = {
|
|
1320
|
+
...this.headers,
|
|
1321
|
+
Accept: "text/event-stream",
|
|
1322
|
+
"Cache-Control": "no-cache"
|
|
1323
|
+
};
|
|
1324
|
+
const response = await fetch(url, { headers });
|
|
1325
|
+
if (!response.ok || !response.body) {
|
|
1326
|
+
throw new Error(`SSE connection failed: ${response.status} ${response.statusText}`);
|
|
1327
|
+
}
|
|
1328
|
+
const reader = response.body.getReader();
|
|
1329
|
+
const decoder = new TextDecoder();
|
|
1330
|
+
let buffer = "";
|
|
1331
|
+
try {
|
|
1332
|
+
while (true) {
|
|
1333
|
+
const { done, value } = await reader.read();
|
|
1334
|
+
if (done) break;
|
|
1335
|
+
buffer += decoder.decode(value, { stream: true });
|
|
1336
|
+
let boundary;
|
|
1337
|
+
while ((boundary = buffer.indexOf("\n\n")) !== -1) {
|
|
1338
|
+
const block = buffer.slice(0, boundary);
|
|
1339
|
+
buffer = buffer.slice(boundary + 2);
|
|
1340
|
+
const event = this._parseSseMemoryBlock(block);
|
|
1341
|
+
if (event !== null) yield event;
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
} finally {
|
|
1345
|
+
reader.releaseLock();
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1348
|
+
/** Parse a single SSE event block into a {@link MemoryEvent}. */
|
|
1349
|
+
_parseSseMemoryBlock(block) {
|
|
1350
|
+
let eventType;
|
|
1351
|
+
const dataLines = [];
|
|
1352
|
+
for (const line of block.split("\n")) {
|
|
1353
|
+
if (line.startsWith(":")) continue;
|
|
1354
|
+
if (line.startsWith("event:")) {
|
|
1355
|
+
eventType = line.slice(6).trim();
|
|
1356
|
+
} else if (line.startsWith("data:")) {
|
|
1357
|
+
dataLines.push(line.slice(5).trimStart());
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1360
|
+
if (dataLines.length === 0) return null;
|
|
1361
|
+
try {
|
|
1362
|
+
const parsed = JSON.parse(dataLines.join("\n"));
|
|
1363
|
+
if (eventType && !parsed.event_type) {
|
|
1364
|
+
parsed.event_type = eventType;
|
|
1365
|
+
}
|
|
1366
|
+
return parsed;
|
|
1367
|
+
} catch {
|
|
1368
|
+
return null;
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1254
1371
|
};
|
|
1255
1372
|
|
|
1256
1373
|
// src/types.ts
|