@hasna/conversations 0.2.51 → 0.2.52

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,68 @@
1
+ import type { Database } from "./db.js";
2
+ import { PgAdapterAsync } from "./remote-storage.js";
3
+ export declare const SYNC_EXCLUDED: Set<string>;
4
+ export declare const DEFAULT_CLOUD_TABLES: readonly ["projects", "spaces", "space_members", "space_subscriptions", "agent_presence", "resource_locks", "graph_edges", "feedback"];
5
+ type SyncTable = (typeof DEFAULT_CLOUD_TABLES)[number];
6
+ type Row = Record<string, unknown>;
7
+ export interface CloudConfig {
8
+ mode: "local" | "cloud" | string;
9
+ rds: {
10
+ host?: string;
11
+ port?: number;
12
+ username?: string;
13
+ password?: string;
14
+ database?: string;
15
+ url?: string;
16
+ connectionString?: string;
17
+ };
18
+ }
19
+ export interface SyncResult {
20
+ table: string;
21
+ rowsRead: number;
22
+ rowsWritten: number;
23
+ errors: string[];
24
+ }
25
+ export interface SyncConflict {
26
+ table: string;
27
+ pk: string;
28
+ local: Row;
29
+ remote: Row;
30
+ }
31
+ export declare function getCloudConfig(): CloudConfig;
32
+ export declare function getCloudDatabaseUrl(): string | null;
33
+ export declare function getCloudPg(): Promise<PgAdapterAsync>;
34
+ export declare function runCloudMigrations(remote: PgAdapterAsync): Promise<void>;
35
+ export declare function listSqliteTables(db?: Database): string[];
36
+ export declare function listPgTables(remote: PgAdapterAsync): Promise<string[]>;
37
+ export declare function resolveTables(tables?: string[] | string): SyncTable[];
38
+ export declare function cloudPush(options?: {
39
+ tables?: string[] | string;
40
+ }): Promise<SyncResult[]>;
41
+ export declare function cloudPull(options?: {
42
+ tables?: string[] | string;
43
+ }): Promise<SyncResult[]>;
44
+ export declare function cloudSync(options?: {
45
+ tables?: string[] | string;
46
+ }): Promise<{
47
+ pull: SyncResult[];
48
+ push: SyncResult[];
49
+ }>;
50
+ export declare function syncPush(db: Database, remote: PgAdapterAsync, options: {
51
+ tables: string[];
52
+ }): Promise<SyncResult[]>;
53
+ export declare function syncPull(remote: PgAdapterAsync, db: Database, options: {
54
+ tables: string[];
55
+ }): Promise<SyncResult[]>;
56
+ export declare function ensureConflictsTable(db: Database): void;
57
+ export declare function detectConflicts(localRows: Row[], remoteRows: Row[], table: string, pk: string, tsCol?: string): SyncConflict[];
58
+ export declare function storeConflicts(db: Database, conflicts: SyncConflict[]): void;
59
+ export declare function listConflicts(db: Database, options?: {
60
+ resolved?: boolean;
61
+ }): Row[];
62
+ export declare function detectAndLogConflicts(local: Database, remote: PgAdapterAsync, table: string): Promise<number>;
63
+ export declare function saveFeedback(message: string, email?: string): {
64
+ id: string;
65
+ sent: false;
66
+ error: string;
67
+ };
68
+ export {};
package/dist/lib/db.d.ts CHANGED
@@ -1,4 +1,22 @@
1
- import { SqliteAdapter as Database } from "@hasna/cloud";
1
+ import type { Changes } from "bun:sqlite";
2
+ export interface ConversationsStatement<ReturnType = any, ParamsType extends unknown[] = unknown[]> {
3
+ all(...params: ParamsType): ReturnType[];
4
+ get(...params: ParamsType): ReturnType | null;
5
+ run(...params: ParamsType): Changes;
6
+ }
7
+ export declare class ConversationsDatabase {
8
+ private readonly database;
9
+ constructor(path: string);
10
+ exec(sql: string): Changes;
11
+ all<ReturnType = any>(sql: string, ...params: unknown[]): ReturnType[];
12
+ get<ReturnType = any>(sql: string, ...params: unknown[]): ReturnType | null;
13
+ query<ReturnType = any, ParamsType extends unknown[] = unknown[]>(sql: string): ConversationsStatement<ReturnType, ParamsType>;
14
+ prepare<ReturnType = any, ParamsType extends unknown[] = unknown[]>(sql: string): ConversationsStatement<ReturnType, ParamsType>;
15
+ run(sql: string, ...params: unknown[]): Changes;
16
+ transaction<T>(fn: () => T): T;
17
+ close(): void;
18
+ }
19
+ export type Database = ConversationsDatabase;
2
20
  export declare function getDataDir(): string;
3
21
  export declare function getDbPath(): string;
4
22
  export declare function getDb(): Database;
@@ -0,0 +1,10 @@
1
+ export declare class PgAdapterAsync {
2
+ private readonly pool;
3
+ constructor(connectionString: string);
4
+ run(sql: string, ...params: unknown[]): Promise<{
5
+ changes: number;
6
+ }>;
7
+ all(sql: string, ...params: unknown[]): Promise<unknown[]>;
8
+ get(sql: string, ...params: unknown[]): Promise<unknown | null>;
9
+ close(): Promise<void>;
10
+ }
@@ -6,9 +6,7 @@
6
6
  * Usage:
7
7
  * conversations mcp # Start MCP server on stdio (40+ tools)
8
8
  * conversations-mcp # Direct binary
9
- * conversations-mcp --http # Streamable HTTP on 127.0.0.1:8856
10
9
  */
11
10
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
12
- export declare function buildServer(forHttp?: boolean): McpServer;
13
11
  export declare const server: McpServer;
14
12
  export declare function startMcpServer(): Promise<void>;
@@ -1,7 +1,4 @@
1
1
  import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
- /**
3
- * Register enhanced cloud sync tools for conversations.
4
- * Replaces the generic @hasna/cloud registerCloudTools with
5
- * conflict detection and sync tracking.
6
- */
2
+ import { DEFAULT_CLOUD_TABLES } from "../../lib/cloud-sync.js";
7
3
  export declare function registerCloudSyncTools(server: McpServer): void;
4
+ export { DEFAULT_CLOUD_TABLES };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/conversations",
3
- "version": "0.2.51",
3
+ "version": "0.2.52",
4
4
  "description": "Real-time CLI messaging for AI agents",
5
5
  "type": "module",
6
6
  "bin": {
@@ -47,11 +47,11 @@
47
47
  "license": "Apache-2.0",
48
48
  "devDependencies": {
49
49
  "@types/bun": "latest",
50
+ "@types/pg": "^8.11.11",
50
51
  "@types/react": "^18.2.0",
51
52
  "typescript": "^5"
52
53
  },
53
54
  "dependencies": {
54
- "@hasna/cloud": "^0.1.30",
55
55
  "@modelcontextprotocol/sdk": "^1.26.0",
56
56
  "chalk": "^5.3.0",
57
57
  "commander": "^12.1.0",
@@ -1,17 +0,0 @@
1
- import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
- export declare const DEFAULT_MCP_HTTP_PORT = 8856;
3
- export declare const MCP_HTTP_HOST = "127.0.0.1";
4
- export declare const MCP_SERVICE_NAME = "conversations";
5
- export declare function isHttpMode(args: string[]): boolean;
6
- export declare function isStdioMode(args: string[]): boolean;
7
- export declare function resolveMcpHttpPort(args: string[]): number;
8
- export declare function healthPayload(name?: string): {
9
- status: string;
10
- name: string;
11
- };
12
- export declare function handleMcpRequest(req: Request, buildServer: () => McpServer): Promise<Response>;
13
- export declare function startMcpHttpServer(options: {
14
- name: string;
15
- port: number;
16
- buildServer: () => McpServer;
17
- }): ReturnType<typeof Bun.serve>;
@@ -1 +0,0 @@
1
- export {};