@hasna/conversations 0.1.33 → 0.2.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.
@@ -0,0 +1,58 @@
1
+ export interface GraphEdge {
2
+ from_type: string;
3
+ from_id: string;
4
+ to_type: string;
5
+ to_id: string;
6
+ relation: string;
7
+ weight: number;
8
+ metadata: Record<string, unknown> | null;
9
+ created_at: string;
10
+ updated_at: string;
11
+ }
12
+ export interface RelatedEntity {
13
+ type: string;
14
+ id: string;
15
+ relation: string;
16
+ weight: number;
17
+ }
18
+ export interface AgentNetwork {
19
+ agent: string;
20
+ communicates_with: {
21
+ agent: string;
22
+ message_count: number;
23
+ last_at: string;
24
+ }[];
25
+ spaces: {
26
+ space: string;
27
+ message_count: number;
28
+ }[];
29
+ projects: string[];
30
+ }
31
+ /**
32
+ * Build the knowledge graph from messages, spaces, and projects.
33
+ * Scans all messages to create edges:
34
+ * agent → communicates_with → agent (DM frequency)
35
+ * agent → member_of → space (space membership)
36
+ * agent → posts_in → space (message activity)
37
+ * space → belongs_to → project (space-project link)
38
+ * message → replies_to → message (threading)
39
+ */
40
+ export declare function buildGraph(): {
41
+ edges_created: number;
42
+ edges_updated: number;
43
+ };
44
+ /**
45
+ * Get all entities related to a given entity.
46
+ */
47
+ export declare function getRelated(entityType: string, entityId: string): RelatedEntity[];
48
+ /**
49
+ * Get an agent's communication network.
50
+ */
51
+ export declare function getAgentNetwork(agent: string): AgentNetwork;
52
+ /**
53
+ * Get graph statistics.
54
+ */
55
+ export declare function getGraphStats(): {
56
+ total_edges: number;
57
+ by_relation: Record<string, number>;
58
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,26 @@
1
+ export interface HotSession {
2
+ session_id: string;
3
+ participants: string[];
4
+ space: string | null;
5
+ last_message_at: string;
6
+ message_count: number;
7
+ hotness_score: number;
8
+ metrics: {
9
+ msgs_last_1h: number;
10
+ msgs_last_24h: number;
11
+ unique_agents: number;
12
+ reaction_count: number;
13
+ reply_count: number;
14
+ high_priority_count: number;
15
+ blocker_count: number;
16
+ hours_since_last: number;
17
+ };
18
+ }
19
+ export interface HotSessionsOptions {
20
+ limit?: number;
21
+ min_score?: number;
22
+ space?: string;
23
+ project_id?: string;
24
+ }
25
+ export declare function computeHotness(sessionId: string): HotSession | null;
26
+ export declare function listHotSessions(opts?: HotSessionsOptions): HotSession[];
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,4 @@
1
- import type { Message, SendMessageOptions, ReadMessagesOptions, SearchMessagesOptions } from "../types.js";
1
+ import type { Message, SendMessageOptions, ReadMessagesOptions, SearchMessagesOptions, SearchResult } from "../types.js";
2
2
  /** Strip null/undefined fields from a message for compact output. */
3
3
  export declare function compactMessage(msg: Message): Partial<Message>;
4
4
  export declare function sendMessage(opts: SendMessageOptions): Message;
@@ -28,4 +28,4 @@ export declare function getPinnedMessages(opts?: {
28
28
  }): Message[];
29
29
  export declare function getUnreadBlockers(agent: string): Message[];
30
30
  export declare function getThreadReplies(messageId: number): Message[];
31
- export declare function searchMessages(opts: SearchMessagesOptions): Message[];
31
+ export declare function searchMessages(opts: SearchMessagesOptions): SearchResult[];
@@ -1,4 +1,14 @@
1
1
  import type { Session } from "../types.js";
2
+ export interface SessionActivity {
3
+ session_id: string;
4
+ msgs_last_1h: number;
5
+ msgs_last_24h: number;
6
+ unique_agents: number;
7
+ reply_ratio: number;
8
+ avg_priority: string;
9
+ reaction_count: number;
10
+ is_trending: boolean;
11
+ }
2
12
  /**
3
13
  * List sessions, optionally filtered to those involving a specific agent.
4
14
  * Sessions are derived from messages — no separate sessions table.
@@ -8,3 +18,7 @@ export declare function listSessions(agent?: string): Session[];
8
18
  * Get a single session by ID.
9
19
  */
10
20
  export declare function getSession(sessionId: string): Session | null;
21
+ /**
22
+ * Get activity metrics for a session — velocity, engagement, trending status.
23
+ */
24
+ export declare function getSessionActivity(sessionId: string): SessionActivity | null;
@@ -0,0 +1,36 @@
1
+ import { type TopicWeight } from "./topics.js";
2
+ export interface ConversationSummary {
3
+ session_id: string;
4
+ participants: string[];
5
+ message_count: number;
6
+ date_range: {
7
+ first: string;
8
+ last: string;
9
+ };
10
+ topics: TopicWeight[];
11
+ key_messages: {
12
+ id: number;
13
+ from: string;
14
+ content: string;
15
+ reason: string;
16
+ }[];
17
+ unresolved_blockers: {
18
+ id: number;
19
+ from: string;
20
+ content: string;
21
+ created_at: string;
22
+ }[];
23
+ activity: {
24
+ reply_count: number;
25
+ reaction_count: number;
26
+ avg_priority: string;
27
+ };
28
+ }
29
+ export interface SummaryOptions {
30
+ limit?: number;
31
+ }
32
+ /**
33
+ * Generate a structured summary of a conversation (session or space).
34
+ * Uses message metadata — no LLM needed.
35
+ */
36
+ export declare function getConversationSummary(sessionOrSpace: string, opts?: SummaryOptions): ConversationSummary | null;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,31 @@
1
+ export interface TopicWeight {
2
+ topic: string;
3
+ weight: number;
4
+ count: number;
5
+ }
6
+ /**
7
+ * Extract weighted topics from a text string using TF-style keyword extraction.
8
+ * Filters stopwords, short words, and markdown syntax.
9
+ */
10
+ export declare function extractTopics(text: string, topN?: number): TopicWeight[];
11
+ /**
12
+ * Get topics for a space by aggregating recent messages.
13
+ */
14
+ export declare function getSpaceTopics(spaceName: string, opts?: {
15
+ limit?: number;
16
+ since?: string;
17
+ }): TopicWeight[];
18
+ /**
19
+ * Get topics for a session by aggregating all messages.
20
+ */
21
+ export declare function getSessionTopics(sessionId: string, opts?: {
22
+ limit?: number;
23
+ }): TopicWeight[];
24
+ /**
25
+ * Get trending topics across all spaces or a specific project.
26
+ */
27
+ export declare function getTrendingTopics(opts?: {
28
+ project_id?: string;
29
+ hours?: number;
30
+ top_n?: number;
31
+ }): TopicWeight[];
@@ -0,0 +1 @@
1
+ export {};
package/dist/types.d.ts CHANGED
@@ -113,6 +113,11 @@ export interface SearchMessagesOptions {
113
113
  from?: string;
114
114
  to?: string;
115
115
  limit?: number;
116
+ sort?: "relevance" | "recent";
117
+ }
118
+ export interface SearchResult extends Message {
119
+ snippet: string | null;
120
+ relevance_score: number;
116
121
  }
117
122
  export interface AgentPresence {
118
123
  id: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/conversations",
3
- "version": "0.1.33",
3
+ "version": "0.2.1",
4
4
  "description": "Real-time CLI messaging for AI agents",
5
5
  "type": "module",
6
6
  "bin": {