autonomous-flow-daemon 1.6.0 → 1.9.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.
Files changed (61) hide show
  1. package/CHANGELOG.md +85 -85
  2. package/LICENSE +21 -21
  3. package/README-ko.md +282 -0
  4. package/README.md +282 -266
  5. package/mcp-config.json +10 -10
  6. package/package.json +4 -2
  7. package/src/adapters/index.ts +370 -370
  8. package/src/cli.ts +162 -127
  9. package/src/commands/benchmark.ts +187 -187
  10. package/src/commands/correlate.ts +180 -0
  11. package/src/commands/dashboard.ts +404 -0
  12. package/src/commands/evolution.ts +84 -1
  13. package/src/commands/fix.ts +158 -158
  14. package/src/commands/lang.ts +41 -41
  15. package/src/commands/plugin.ts +110 -0
  16. package/src/commands/restart.ts +14 -14
  17. package/src/commands/score.ts +276 -276
  18. package/src/commands/start.ts +155 -155
  19. package/src/commands/status.ts +157 -157
  20. package/src/commands/stop.ts +68 -68
  21. package/src/commands/suggest.ts +211 -0
  22. package/src/commands/sync.ts +329 -16
  23. package/src/constants.ts +32 -32
  24. package/src/core/boast.ts +280 -280
  25. package/src/core/config.ts +49 -49
  26. package/src/core/correlation-engine.ts +265 -0
  27. package/src/core/db.ts +145 -117
  28. package/src/core/discovery.ts +65 -65
  29. package/src/core/federation.ts +129 -0
  30. package/src/core/hologram/engine.ts +71 -71
  31. package/src/core/hologram/fallback.ts +11 -11
  32. package/src/core/hologram/go-extractor.ts +203 -0
  33. package/src/core/hologram/incremental.ts +227 -227
  34. package/src/core/hologram/py-extractor.ts +132 -132
  35. package/src/core/hologram/rust-extractor.ts +244 -0
  36. package/src/core/hologram/ts-extractor.ts +406 -320
  37. package/src/core/hologram/types.ts +27 -25
  38. package/src/core/hologram.ts +73 -71
  39. package/src/core/i18n/messages.ts +309 -309
  40. package/src/core/locale.ts +88 -88
  41. package/src/core/log-rotate.ts +33 -33
  42. package/src/core/log-utils.ts +38 -38
  43. package/src/core/lru-map.ts +61 -61
  44. package/src/core/notify.ts +74 -74
  45. package/src/core/plugin-manager.ts +225 -0
  46. package/src/core/rule-suggestion.ts +127 -0
  47. package/src/core/validator-generator.ts +224 -0
  48. package/src/core/workspace.ts +28 -28
  49. package/src/daemon/client.ts +78 -65
  50. package/src/daemon/event-batcher.ts +108 -108
  51. package/src/daemon/guards.ts +13 -13
  52. package/src/daemon/http-routes.ts +376 -293
  53. package/src/daemon/mcp-handler.ts +575 -270
  54. package/src/daemon/mcp-subscriptions.ts +81 -0
  55. package/src/daemon/mesh.ts +51 -0
  56. package/src/daemon/server.ts +655 -590
  57. package/src/daemon/types.ts +121 -100
  58. package/src/daemon/workspace-map.ts +104 -92
  59. package/src/platform.ts +60 -60
  60. package/src/version.ts +15 -15
  61. package/README.ko.md +0 -266
@@ -0,0 +1,81 @@
1
+ /**
2
+ * MCP Subscription Manager — v1.9.0 MCP Phase 3
3
+ *
4
+ * MCP 2024-11-05 스펙의 `resources/subscribe` 프로토콜 구현.
5
+ * 구독된 URI에 대해 `notifications/resources/updated`를 push-based로 전송한다.
6
+ */
7
+
8
+ /** 구독 중인 URI 집합 관리 + 알림 발송 */
9
+ export class SubscriptionManager {
10
+ private subscriptions = new Set<string>();
11
+ private active = false;
12
+
13
+ /** MCP stdio 모드 활성화 (서버 시작 시 호출) */
14
+ enable(): void {
15
+ this.active = true;
16
+ }
17
+
18
+ subscribe(uri: string): void {
19
+ this.subscriptions.add(uri);
20
+ }
21
+
22
+ unsubscribe(uri: string): void {
23
+ this.subscriptions.delete(uri);
24
+ }
25
+
26
+ isSubscribed(uri: string): boolean {
27
+ return this.subscriptions.has(uri);
28
+ }
29
+
30
+ /**
31
+ * 구독된 URI에 notifications/resources/updated 발송.
32
+ * MCP 모드가 아니거나 구독자가 없으면 no-op.
33
+ */
34
+ dispatchResourceUpdated(uri: string): void {
35
+ if (!this.active || !this.subscriptions.has(uri)) return;
36
+ try {
37
+ process.stdout.write(
38
+ JSON.stringify({
39
+ jsonrpc: "2.0",
40
+ method: "notifications/resources/updated",
41
+ params: { uri },
42
+ }) + "\n"
43
+ );
44
+ } catch { /* crash-only */ }
45
+ }
46
+
47
+ /**
48
+ * notifications/resources/list_changed 발송.
49
+ * 새로운 동적 리소스가 생성될 때 호출.
50
+ */
51
+ dispatchListChanged(): void {
52
+ if (!this.active) return;
53
+ try {
54
+ process.stdout.write(
55
+ JSON.stringify({
56
+ jsonrpc: "2.0",
57
+ method: "notifications/resources/list_changed",
58
+ }) + "\n"
59
+ );
60
+ } catch { /* crash-only */ }
61
+ }
62
+
63
+ /**
64
+ * notifications/message 발송 (레벨: "debug" | "info" | "warning" | "error").
65
+ */
66
+ dispatchMessage(level: "debug" | "info" | "warning" | "error", data: string): void {
67
+ if (!this.active) return;
68
+ try {
69
+ process.stdout.write(
70
+ JSON.stringify({
71
+ jsonrpc: "2.0",
72
+ method: "notifications/message",
73
+ params: { level, data },
74
+ }) + "\n"
75
+ );
76
+ } catch { /* crash-only */ }
77
+ }
78
+ }
79
+
80
+ /** 모듈 수준 싱글톤 — server.ts와 mcp-handler.ts가 공유 */
81
+ export const subscriptionManager = new SubscriptionManager();
@@ -0,0 +1,51 @@
1
+ import { readFileSync, writeFileSync, mkdirSync, existsSync } from "fs";
2
+ import { homedir } from "os";
3
+ import { join } from "path";
4
+
5
+ const MESH_DIR = join(homedir(), ".afd");
6
+ const MESH_FILE = join(MESH_DIR, "mesh.json");
7
+
8
+ export interface MeshEntry {
9
+ workspace: string;
10
+ port: number;
11
+ pid: number;
12
+ registeredAt: number;
13
+ }
14
+
15
+ function readRegistry(): MeshEntry[] {
16
+ if (!existsSync(MESH_FILE)) return [];
17
+ try {
18
+ return JSON.parse(readFileSync(MESH_FILE, "utf-8")) as MeshEntry[];
19
+ } catch {
20
+ return [];
21
+ }
22
+ }
23
+
24
+ function writeRegistry(entries: MeshEntry[]): void {
25
+ mkdirSync(MESH_DIR, { recursive: true });
26
+ writeFileSync(MESH_FILE, JSON.stringify(entries, null, 2));
27
+ }
28
+
29
+ function isAlive(pid: number): boolean {
30
+ try {
31
+ process.kill(pid, 0);
32
+ return true;
33
+ } catch {
34
+ return false;
35
+ }
36
+ }
37
+
38
+ export function registerMesh(workspace: string, port: number, pid: number): void {
39
+ const entries = readRegistry().filter(e => e.workspace !== workspace && isAlive(e.pid));
40
+ entries.push({ workspace, port, pid, registeredAt: Date.now() });
41
+ writeRegistry(entries);
42
+ }
43
+
44
+ export function deregisterMesh(workspace: string): void {
45
+ const entries = readRegistry().filter(e => e.workspace !== workspace && isAlive(e.pid));
46
+ writeRegistry(entries);
47
+ }
48
+
49
+ export function listMeshPeers(currentWorkspace: string): MeshEntry[] {
50
+ return readRegistry().filter(e => e.workspace !== currentWorkspace && isAlive(e.pid));
51
+ }