synapse-causal-memory 0.2.2 → 0.2.3

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.
@@ -15,6 +15,10 @@ export declare const CAUSAL_MEMORY_CONFIG: {
15
15
  readonly DEFAULT_HOST: string;
16
16
  /** 독립 로컬 데몬 서버 기본 포트 */
17
17
  readonly DEFAULT_PORT: number;
18
+ /** 원격 Causal Memory 데몬 프록시 URL (예: Tailscale 피어 http://100.82.92.122:4242) */
19
+ readonly REMOTE_URL: string;
20
+ /** 원격 요청 제한 시간 (ms) */
21
+ readonly REMOTE_TIMEOUT_MS: number;
18
22
  /** MCP 서버 프로토콜 버전 */
19
23
  readonly MCP_PROTOCOL_VERSION: string;
20
24
  /** MCP 서버 식별 이름 */
@@ -0,0 +1,53 @@
1
+ import type { CausalQueryOptions, CausalResonanceResult } from './causal-store';
2
+ export interface TailscalePeerNode {
3
+ readonly id: string;
4
+ readonly hostName: string;
5
+ readonly ip: string;
6
+ readonly os: string;
7
+ readonly online: boolean;
8
+ readonly active: boolean;
9
+ readonly isSelf: boolean;
10
+ }
11
+ export interface PeerHealthResult {
12
+ readonly host: string;
13
+ readonly port: number;
14
+ readonly url: string;
15
+ readonly reachable: boolean;
16
+ readonly rttMs: number;
17
+ readonly version?: string;
18
+ readonly totalRules?: number;
19
+ readonly totalRelations?: number;
20
+ readonly error?: string;
21
+ }
22
+ export interface PeerSyncResult {
23
+ readonly targetHost: string;
24
+ readonly direction: 'pull' | 'push';
25
+ readonly success: boolean;
26
+ readonly durationMs: number;
27
+ readonly addedRules?: number;
28
+ readonly updatedRules?: number;
29
+ readonly addedRelations?: number;
30
+ readonly totalRules?: number;
31
+ readonly totalRelations?: number;
32
+ readonly error?: string;
33
+ }
34
+ /**
35
+ * Tailscale CLI 상태를 파싱하여 활성 피어 목록을 조회합니다.
36
+ */
37
+ export declare function getTailscalePeers(): Promise<{
38
+ selfIp?: string;
39
+ selfHost?: string;
40
+ peers: TailscalePeerNode[];
41
+ }>;
42
+ /**
43
+ * 대상 호스트의 Causal Memory Daemon 헬스체크 및 RTT 측정
44
+ */
45
+ export declare function pingPeer(host: string, port?: number): Promise<PeerHealthResult>;
46
+ /**
47
+ * 원격 Causal Memory Daemon에 공명 쿼리 실행
48
+ */
49
+ export declare function queryRemotePeer(remoteUrl: string, options: CausalQueryOptions): Promise<CausalResonanceResult>;
50
+ /**
51
+ * 피어 노드 간 인과율 규칙 및 간선 동기화 (Sync)
52
+ */
53
+ export declare function syncWithPeer(remoteHost: string, port?: number, direction?: 'pull' | 'push', dbPath?: string): Promise<PeerSyncResult>;
@@ -294,6 +294,7 @@ export declare function startCausalServer(options?: ServerOptions): Bun.Server<u
294
294
  /**
295
295
  * MCP 표준 입출력(stdio) 서버 모드
296
296
  * Antigravity / Claude Code 등의 MCP 호스트가 프로세스를 직접 스폰하여 통신할 때 동작합니다.
297
- * 로컬 데몬(4242 포트)이 실행 중이면 데몬으로 프록시하고, 꺼져 있으면 인메모리 스토어로 즉시 응답합니다.
297
+ * 원격 데몬 URL(Tailscale 피어 등) 또는 로컬 데몬(4242 포트)이 지정/실행 중이면 데몬으로 프록시하고,
298
+ * 꺼져 있으면 인메모리 스토어로 즉시 안전하게 응답합니다.
298
299
  */
299
- export declare function startCausalMcpStdioServer(dbPath?: string): Promise<void>;
300
+ export declare function startCausalMcpStdioServer(dbPath?: string, remoteUrl?: string): Promise<void>;
@@ -104,6 +104,14 @@ export declare class CausalMemoryStore {
104
104
  * O(1) 역인덱스(Inverted Index) 및 인접 리스트 그래프(Adjacency List) 재구축
105
105
  */
106
106
  private rebuildIndices;
107
+ /**
108
+ * 동일 제목(title) 규칙 중복 시 도메인 우선순위 점수 산출
109
+ */
110
+ private static getRuleDomainPriority;
111
+ /**
112
+ * 규칙 배열에서 동일 제목(title) 중복 제거 및 정규화
113
+ */
114
+ private static deduplicateRulesByTitle;
107
115
  /**
108
116
  * 데이터베이스 로드
109
117
  */
@@ -215,6 +223,10 @@ export declare class CausalMemoryStore {
215
223
  * 구형 memory MCP 호환: create_relations
216
224
  */
217
225
  createRelations(relations: readonly CausalRelation[], persistToDisk?: boolean): CausalRelation[];
226
+ /**
227
+ * 단일 인과 규칙 삭제 (연결된 고아 인과 간선 동시 정리)
228
+ */
229
+ deleteRule(ruleId: string, persistToDisk?: boolean): boolean;
218
230
  /**
219
231
  * 구형 memory MCP 호환: delete_entities
220
232
  */
@@ -244,4 +256,18 @@ export declare class CausalMemoryStore {
244
256
  alwaysActiveCount: number;
245
257
  issues: string[];
246
258
  };
259
+ /**
260
+ * 원시 데이터베이스 객체 반환 (백업 및 피어 동기화용)
261
+ */
262
+ getRawDatabase(): CausalMemoryDatabase;
263
+ /**
264
+ * 원격 피어 데이터베이스와 로컬 데이터베이스 양방향 무손실 병합 (Sync)
265
+ */
266
+ mergeDatabase(incomingRules: readonly CausalRule[], incomingRelations?: readonly CausalRelation[]): {
267
+ addedRules: number;
268
+ updatedRules: number;
269
+ addedRelations: number;
270
+ totalRules: number;
271
+ totalRelations: number;
272
+ };
247
273
  }
package/dist/cli.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ #!/usr/bin/env bun
1
2
  export interface MemoryCliOptions {
2
3
  lang?: string;
3
4
  compact?: boolean;