atabey 0.0.8 → 0.0.9

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/README.md CHANGED
@@ -190,7 +190,7 @@ Başarılı bir `init` kurulumundan sonra projenizin kök dizininde şu yapı ol
190
190
  * **.atabey/memory/PROJECT_MEMORY.md:** Aktif geliştirme bağlamı ve bellek dosyası.
191
191
  * **.atabey/memory-graph/shared-facts.json:** Proje teknoloji yığını ve temel gerçekleri.
192
192
 
193
- ## [NEW] Changelog / Güncellemeler (v0.0.8)
193
+ ## [NEW] Changelog / Güncellemeler (v0.0.9)
194
194
 
195
195
  ### [TR] Türkçe
196
196
  * **Taşınabilir MCP Yolları:** `atabey init` esnasında üretilen `mcp.json` ayarlarında yerel `npx` cache veya mutlak kullanıcı yolları yerine, projenin kendi `node_modules/atabey/framework-mcp/dist/index.js` altındaki taşınabilir göreli yollar kullanılmaya başlandı.
@@ -1,4 +1,4 @@
1
- import { Storage } from "../../../src/shared/storage.js";
1
+ import { Storage } from "../utils/storage.js";
2
2
  /**
3
3
  * [DATA] MCP Resource Definitions
4
4
  */
@@ -43,7 +43,7 @@ export async function handleReadResource(uri) {
43
43
  if (uri === "atabey://memory/project") {
44
44
  const fs = await import("fs");
45
45
  const path = await import("path");
46
- const { getFrameworkDir } = await import("../../../src/cli/utils/memory.js");
46
+ const { getFrameworkDir } = await import("../utils/memory.js");
47
47
  const projectRoot = process.env.ATABEY_PROJECT_ROOT || process.cwd();
48
48
  const fwDir = getFrameworkDir();
49
49
  const p = path.isAbsolute(fwDir)
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../framework-mcp/src/resources/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAqB,MAAM,gCAAgC,CAAC;AAE5E;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACrB;QACI,GAAG,EAAE,sBAAsB;QAC3B,IAAI,EAAE,mBAAmB;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,CAAC;QAClC,MAAM,EAAE,eAAe,EAAE,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC,CAAC;QAE/D,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QACrE,MAAM,KAAK,GAAG,eAAe,EAAE,CAAC;QAChC,MAAM,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC;YAC5B,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,mBAAmB,CAAC;YACjD,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAE,mBAAmB,CAAC,CAAC;QAEnE,IAAI,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC;YACnB,OAAO,EAAE,CAAC,YAAY,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;QACtC,CAAC;QACD,OAAO,oDAAoD,CAAC;IAChE,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,yBAAyB,GAAG,EAAE,CAAC,CAAC;AACpD,CAAC"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Enterprise Base Error class for the Agent Atabey Framework.
3
+ */
4
+ export declare class AtabeyBaseError extends Error {
5
+ readonly code: string;
6
+ readonly timestamp: Date;
7
+ readonly details?: unknown;
8
+ readonly solution?: string;
9
+ constructor(message: string, code?: string, details?: unknown, solution?: string);
10
+ /**
11
+ * Converts the error into a structured JSON log format.
12
+ */
13
+ toJSON(): {
14
+ name: string;
15
+ message: string;
16
+ code: string;
17
+ timestamp: string;
18
+ details: unknown;
19
+ solution: string | undefined;
20
+ stack: string | undefined;
21
+ };
22
+ }
23
+ /**
24
+ * Thrown when configuration loading or validation fails.
25
+ */
26
+ export declare class ConfigurationError extends AtabeyBaseError {
27
+ constructor(message: string, details?: unknown, solution?: string);
28
+ }
29
+ /**
30
+ * Thrown when data schema or payload validation fails.
31
+ */
32
+ export declare class ValidationError extends AtabeyBaseError {
33
+ constructor(message: string, details?: unknown, solution?: string);
34
+ }
35
+ /**
36
+ * Thrown when adapter initialization or execution fails.
37
+ */
38
+ export declare class AdapterError extends AtabeyBaseError {
39
+ constructor(message: string, adapterId: string, details?: unknown, solution?: string);
40
+ }
41
+ /**
42
+ * Thrown when orchestration or agent communication fails.
43
+ */
44
+ export declare class OrchestrationError extends AtabeyBaseError {
45
+ constructor(message: string, details?: unknown, solution?: string);
46
+ }
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Enterprise Base Error class for the Agent Atabey Framework.
3
+ */
4
+ export class AtabeyBaseError extends Error {
5
+ code;
6
+ timestamp;
7
+ details;
8
+ solution;
9
+ constructor(message, code = "ATABEY_INTERNAL_ERROR", details, solution) {
10
+ super(message);
11
+ this.name = this.constructor.name;
12
+ this.code = code;
13
+ this.timestamp = new Date();
14
+ this.details = details;
15
+ this.solution = solution;
16
+ // Ensure proper prototype chain and capture stack trace
17
+ Object.setPrototypeOf(this, new.target.prototype);
18
+ if (Error.captureStackTrace) {
19
+ Error.captureStackTrace(this, this.constructor);
20
+ }
21
+ }
22
+ /**
23
+ * Converts the error into a structured JSON log format.
24
+ */
25
+ toJSON() {
26
+ return {
27
+ name: this.name,
28
+ message: this.message,
29
+ code: this.code,
30
+ timestamp: this.timestamp.toISOString(),
31
+ details: this.details,
32
+ solution: this.solution,
33
+ stack: this.stack,
34
+ };
35
+ }
36
+ }
37
+ /**
38
+ * Thrown when configuration loading or validation fails.
39
+ */
40
+ export class ConfigurationError extends AtabeyBaseError {
41
+ constructor(message, details, solution) {
42
+ super(message, "CONFIGURATION_ERROR", details, solution);
43
+ }
44
+ }
45
+ /**
46
+ * Thrown when data schema or payload validation fails.
47
+ */
48
+ export class ValidationError extends AtabeyBaseError {
49
+ constructor(message, details, solution) {
50
+ super(message, "VALIDATION_ERROR", details, solution);
51
+ }
52
+ }
53
+ /**
54
+ * Thrown when adapter initialization or execution fails.
55
+ */
56
+ export class AdapterError extends AtabeyBaseError {
57
+ constructor(message, adapterId, details, solution) {
58
+ super(`Adapter '${adapterId}' failure: ${message}`, "ADAPTER_ERROR", details, solution);
59
+ }
60
+ }
61
+ /**
62
+ * Thrown when orchestration or agent communication fails.
63
+ */
64
+ export class OrchestrationError extends AtabeyBaseError {
65
+ constructor(message, details, solution) {
66
+ super(message, "ORCHESTRATION_ERROR", details, solution);
67
+ }
68
+ }
69
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../../framework-mcp/src/utils/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACtB,IAAI,CAAS;IACb,SAAS,CAAO;IAChB,OAAO,CAAW;IAClB,QAAQ,CAAU;IAElC,YAAY,OAAe,EAAE,IAAI,GAAG,uBAAuB,EAAE,OAAiB,EAAE,QAAiB;QAC7F,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;QAClC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;QAC5B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAEzB,wDAAwD;QACxD,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAClD,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAC1B,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QACpD,CAAC;IACL,CAAC;IAED;;OAEG;IACI,MAAM;QACT,OAAO;YACH,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE;YACvC,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,KAAK,EAAE,IAAI,CAAC,KAAK;SACpB,CAAC;IACN,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,eAAe;IACnD,YAAY,OAAe,EAAE,OAAiB,EAAE,QAAiB;QAC7D,KAAK,CAAC,OAAO,EAAE,qBAAqB,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC7D,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,eAAe;IAChD,YAAY,OAAe,EAAE,OAAiB,EAAE,QAAiB;QAC7D,KAAK,CAAC,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC1D,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,OAAO,YAAa,SAAQ,eAAe;IAC7C,YAAY,OAAe,EAAE,SAAiB,EAAE,OAAiB,EAAE,QAAiB;QAChF,KAAK,CAAC,YAAY,SAAS,cAAc,OAAO,EAAE,EAAE,eAAe,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC5F,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,eAAe;IACnD,YAAY,OAAe,EAAE,OAAiB,EAAE,QAAiB;QAC7D,KAAK,CAAC,OAAO,EAAE,qBAAqB,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC7D,CAAC;CACJ"}
@@ -0,0 +1,3 @@
1
+ export declare function isFrameworkDevelopmentRepo(): boolean;
2
+ export declare function getConfigDir(): string;
3
+ export declare function getFrameworkDir(): string;
@@ -0,0 +1,75 @@
1
+ import fs from "fs";
2
+ import os from "os";
3
+ import path from "path";
4
+ const CWD = process.cwd();
5
+ const HOME = os.homedir();
6
+ const FRAMEWORK = {
7
+ CORE_DIR: ".atabey",
8
+ };
9
+ const FRAMEWORK_DIR_CANDIDATES = [
10
+ ".atabey",
11
+ ".agents",
12
+ ".claude",
13
+ ".gemini",
14
+ ".grok",
15
+ ".cursor",
16
+ ];
17
+ const MCP = {
18
+ TEST_DIR_ENV: "ATABEY_TEST_DIR",
19
+ };
20
+ function findFrameworkDir(basePath) {
21
+ try {
22
+ const pkgPath = path.join(basePath, "package.json");
23
+ if (fs.existsSync(pkgPath)) {
24
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
25
+ if (pkg.atabey && typeof pkg.atabey.frameworkDir === "string") {
26
+ const customDir = path.join(basePath, pkg.atabey.frameworkDir);
27
+ if (fs.existsSync(customDir))
28
+ return customDir;
29
+ }
30
+ }
31
+ }
32
+ catch {
33
+ // ignore
34
+ }
35
+ return null;
36
+ }
37
+ export function isFrameworkDevelopmentRepo() {
38
+ try {
39
+ const pkgPath = path.join(CWD, "package.json");
40
+ if (fs.existsSync(pkgPath)) {
41
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
42
+ if (pkg.name === "atabey") {
43
+ return true;
44
+ }
45
+ }
46
+ }
47
+ catch {
48
+ // ignore
49
+ }
50
+ return false;
51
+ }
52
+ export function getConfigDir() {
53
+ const localDir = findFrameworkDir(CWD);
54
+ if (localDir)
55
+ return localDir;
56
+ // Check for standard local directories if package.json doesn't specify
57
+ const localCandidates = [...FRAMEWORK_DIR_CANDIDATES, ".agent"];
58
+ for (const cand of localCandidates) {
59
+ const p = path.join(CWD, cand);
60
+ if (fs.existsSync(p))
61
+ return p;
62
+ }
63
+ // In dev repo, don't fall back to global dir. Point to local default.
64
+ if (isFrameworkDevelopmentRepo()) {
65
+ return path.join(CWD, FRAMEWORK.CORE_DIR);
66
+ }
67
+ return path.join(HOME, FRAMEWORK.CORE_DIR);
68
+ }
69
+ export function getFrameworkDir() {
70
+ const testDir = process.env[MCP.TEST_DIR_ENV];
71
+ if (testDir)
72
+ return testDir;
73
+ return getConfigDir();
74
+ }
75
+ //# sourceMappingURL=memory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.js","sourceRoot":"","sources":["../../../../framework-mcp/src/utils/memory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;AAC1B,MAAM,IAAI,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC;AAE1B,MAAM,SAAS,GAAG;IACd,QAAQ,EAAE,SAAS;CACtB,CAAC;AAEF,MAAM,wBAAwB,GAAG;IAC7B,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,OAAO;IACP,SAAS;CACZ,CAAC;AAEF,MAAM,GAAG,GAAG;IACR,YAAY,EAAE,iBAAiB;CAClC,CAAC;AAEF,SAAS,gBAAgB,CAAC,QAAgB;IACtC,IAAI,CAAC;QACD,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;QACpD,IAAI,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;YACzB,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;YACzD,IAAI,GAAG,CAAC,MAAM,IAAI,OAAO,GAAG,CAAC,MAAM,CAAC,YAAY,KAAK,QAAQ,EAAE,CAAC;gBAC5D,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;gBAC/D,IAAI,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC;oBAAE,OAAO,SAAS,CAAC;YACnD,CAAC;QACL,CAAC;IACL,CAAC;IAAC,MAAM,CAAC;QAC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AO,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAC9C,IAAI,OAAO;QAAE,OAAO,OAAO,CAAC;IAC5B,OAAO,YAAY,EAAE,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,60 @@
1
+ import Database from "better-sqlite3";
2
+ import { TraceID } from "./types.js";
3
+ export interface AgentRow {
4
+ name: string;
5
+ state: string;
6
+ task: string;
7
+ last_updated: string;
8
+ }
9
+ export interface MessageRow {
10
+ id?: number;
11
+ timestamp: string;
12
+ from: string;
13
+ to: string;
14
+ category: string;
15
+ content: string;
16
+ traceId: TraceID;
17
+ parentId?: string;
18
+ status: string;
19
+ priority: string;
20
+ requiresApproval: boolean;
21
+ }
22
+ export interface TaskRow {
23
+ id: string;
24
+ traceId: TraceID;
25
+ description: string;
26
+ agent: string;
27
+ status: string;
28
+ priority: string;
29
+ dependencies: string[];
30
+ }
31
+ export interface LogRow {
32
+ id?: number;
33
+ timestamp: string;
34
+ agent: string;
35
+ action: string;
36
+ trace_id?: TraceID;
37
+ status: string;
38
+ summary: string;
39
+ findings?: string;
40
+ }
41
+ /**
42
+ * [DB] Atabey Storage Engine
43
+ * Central SQLite database for enterprise-scale agent state management.
44
+ */
45
+ export declare class Storage {
46
+ private static db;
47
+ static getDB(): Database.Database;
48
+ private static initializeSchema;
49
+ static updateAgentStatus(name: string, state: string, task: string, lastUpdated?: string): void;
50
+ static getAllAgents(): AgentRow[];
51
+ static saveMessage(msg: MessageRow): void;
52
+ static getPendingMessages(): MessageRow[];
53
+ static updateMessageStatus(id: number, status: string): void;
54
+ static saveTask(task: TaskRow): void;
55
+ static getTasks(traceId?: TraceID): TaskRow[];
56
+ static getLogs(agentName?: string): LogRow[];
57
+ static setMetadata(key: string, value: string): void;
58
+ static getMetadata(key: string): string | null;
59
+ static reset(): void;
60
+ }
@@ -0,0 +1,208 @@
1
+ import Database from "better-sqlite3";
2
+ import path from "path";
3
+ import fs from "fs";
4
+ import { getFrameworkDir } from "./memory.js";
5
+ /**
6
+ * [DB] Atabey Storage Engine
7
+ * Central SQLite database for enterprise-scale agent state management.
8
+ */
9
+ export class Storage {
10
+ static db = null;
11
+ static getDB() {
12
+ if (!this.db) {
13
+ const frameworkDir = getFrameworkDir();
14
+ if (!fs.existsSync(frameworkDir)) {
15
+ fs.mkdirSync(frameworkDir, { recursive: true });
16
+ }
17
+ const dbPath = path.join(frameworkDir, "atabey.db");
18
+ this.db = new Database(dbPath);
19
+ this.initializeSchema();
20
+ }
21
+ return this.db;
22
+ }
23
+ static initializeSchema() {
24
+ const db = this.db;
25
+ // Agents Table
26
+ db.exec(`
27
+ CREATE TABLE IF NOT EXISTS agents (
28
+ name TEXT PRIMARY KEY,
29
+ state TEXT DEFAULT 'READY',
30
+ task TEXT DEFAULT 'Idle',
31
+ last_updated DATETIME DEFAULT CURRENT_TIMESTAMP
32
+ )
33
+ `);
34
+ // Messages (Hermes) Table
35
+ db.exec(`
36
+ CREATE TABLE IF NOT EXISTS messages (
37
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
38
+ timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
39
+ sender TEXT,
40
+ receiver TEXT,
41
+ category TEXT,
42
+ content TEXT,
43
+ trace_id TEXT,
44
+ parent_id TEXT,
45
+ status TEXT DEFAULT 'PENDING',
46
+ priority TEXT DEFAULT 'NORMAL',
47
+ requires_approval BOOLEAN DEFAULT 0
48
+ )
49
+ `);
50
+ // Tasks Table
51
+ db.exec(`
52
+ CREATE TABLE IF NOT EXISTS tasks (
53
+ id TEXT PRIMARY KEY,
54
+ trace_id TEXT,
55
+ description TEXT,
56
+ agent TEXT,
57
+ status TEXT DEFAULT 'PENDING',
58
+ priority TEXT DEFAULT 'NORMAL',
59
+ dependencies TEXT, -- JSON Array
60
+ created_at DATETIME DEFAULT CURRENT_TIMESTAMP
61
+ )
62
+ `);
63
+ // Logs Table
64
+ db.exec(`
65
+ CREATE TABLE IF NOT EXISTS logs (
66
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
67
+ timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
68
+ agent TEXT,
69
+ action TEXT,
70
+ trace_id TEXT,
71
+ status TEXT,
72
+ summary TEXT,
73
+ findings TEXT
74
+ )
75
+ `);
76
+ // Metadata (State) Table
77
+ db.exec(`
78
+ CREATE TABLE IF NOT EXISTS metadata (
79
+ key TEXT PRIMARY KEY,
80
+ value TEXT
81
+ )
82
+ `);
83
+ }
84
+ // --- Agent Operations ---
85
+ static updateAgentStatus(name, state, task, lastUpdated) {
86
+ const db = this.getDB();
87
+ const cleanName = name.replace("@", "");
88
+ const timestamp = lastUpdated || new Date().toISOString();
89
+ db.prepare(`
90
+ INSERT INTO agents (name, state, task, last_updated)
91
+ VALUES (?, ?, ?, ?)
92
+ ON CONFLICT(name) DO UPDATE SET
93
+ state = excluded.state,
94
+ task = excluded.task,
95
+ last_updated = excluded.last_updated
96
+ `).run(cleanName, state, task, timestamp);
97
+ }
98
+ static getAllAgents() {
99
+ return this.getDB().prepare("SELECT * FROM agents").all();
100
+ }
101
+ // --- Message Operations ---
102
+ static saveMessage(msg) {
103
+ const db = this.getDB();
104
+ db.prepare(`
105
+ INSERT INTO messages (sender, receiver, category, content, trace_id, parent_id, status, priority, requires_approval)
106
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
107
+ `).run(msg.from, msg.to, msg.category, msg.content, msg.traceId, msg.parentId || null, msg.status || "PENDING", msg.priority || "NORMAL", msg.requiresApproval ? 1 : 0);
108
+ }
109
+ static getPendingMessages() {
110
+ const rows = this.getDB().prepare("SELECT * FROM messages WHERE status IN ('PENDING', 'APPROVED') ORDER BY priority DESC, timestamp ASC").all();
111
+ return rows.map(r => ({
112
+ id: r.id,
113
+ timestamp: r.timestamp,
114
+ from: r.sender,
115
+ to: r.receiver,
116
+ category: r.category,
117
+ content: r.content,
118
+ traceId: r.trace_id,
119
+ parentId: r.parent_id || undefined,
120
+ status: r.status,
121
+ priority: r.priority,
122
+ requiresApproval: r.requires_approval === 1
123
+ }));
124
+ }
125
+ static updateMessageStatus(id, status) {
126
+ this.getDB().prepare("UPDATE messages SET status = ? WHERE id = ?").run(status, id);
127
+ }
128
+ // --- Task Operations ---
129
+ static saveTask(task) {
130
+ const db = this.getDB();
131
+ db.prepare(`
132
+ INSERT INTO tasks (id, trace_id, description, agent, status, priority, dependencies)
133
+ VALUES (?, ?, ?, ?, ?, ?, ?)
134
+ ON CONFLICT(id) DO UPDATE SET
135
+ status = excluded.status,
136
+ description = excluded.description
137
+ `).run(task.id, task.traceId, task.description, task.agent, task.status, task.priority, JSON.stringify(task.dependencies || []));
138
+ }
139
+ static getTasks(traceId) {
140
+ const db = this.getDB();
141
+ let rows;
142
+ if (traceId) {
143
+ rows = db.prepare("SELECT * FROM tasks WHERE trace_id = ?").all(traceId);
144
+ }
145
+ else {
146
+ rows = db.prepare("SELECT * FROM tasks").all();
147
+ }
148
+ return rows.map(r => {
149
+ let deps = [];
150
+ try {
151
+ const parsed = JSON.parse(r.dependencies || "[]");
152
+ // Handle cases where dependencies might be double-stringified or are raw JSON strings
153
+ deps = Array.isArray(parsed) ? parsed : JSON.parse(parsed);
154
+ }
155
+ catch {
156
+ // Keep empty array
157
+ }
158
+ return {
159
+ id: r.id,
160
+ traceId: r.trace_id,
161
+ description: r.description,
162
+ agent: r.agent,
163
+ status: r.status,
164
+ priority: r.priority,
165
+ dependencies: deps
166
+ };
167
+ });
168
+ }
169
+ static getLogs(agentName) {
170
+ const db = this.getDB();
171
+ let rows;
172
+ const cleanName = agentName ? agentName.replace("@", "") : undefined;
173
+ if (cleanName) {
174
+ rows = db.prepare("SELECT * FROM logs WHERE agent = ? ORDER BY timestamp DESC").all(cleanName);
175
+ }
176
+ else {
177
+ rows = db.prepare("SELECT * FROM logs ORDER BY timestamp DESC").all();
178
+ }
179
+ return rows.map(r => ({
180
+ id: r.id,
181
+ timestamp: r.timestamp,
182
+ agent: r.agent,
183
+ action: r.action,
184
+ trace_id: r.trace_id || undefined,
185
+ status: r.status,
186
+ summary: r.summary,
187
+ findings: r.findings || undefined
188
+ }));
189
+ }
190
+ // --- Metadata Operations ---
191
+ static setMetadata(key, value) {
192
+ this.getDB().prepare(`
193
+ INSERT INTO metadata (key, value) VALUES (?, ?)
194
+ ON CONFLICT(key) DO UPDATE SET value = excluded.value
195
+ `).run(key, value);
196
+ }
197
+ static getMetadata(key) {
198
+ const row = this.getDB().prepare("SELECT value FROM metadata WHERE key = ?").get(key);
199
+ return row ? row.value : null;
200
+ }
201
+ static reset() {
202
+ if (this.db) {
203
+ this.db.close();
204
+ this.db = null;
205
+ }
206
+ }
207
+ }
208
+ //# sourceMappingURL=storage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.js","sourceRoot":"","sources":["../../../../framework-mcp/src/utils/storage.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AA6C9C;;;GAGG;AACH,MAAM,OAAO,OAAO;IACR,MAAM,CAAC,EAAE,GAA6B,IAAI,CAAC;IAE5C,MAAM,CAAC,KAAK;QACf,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;YACX,MAAM,YAAY,GAAG,eAAe,EAAE,CAAC;YACvC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;gBAC/B,EAAE,CAAC,SAAS,CAAC,YAAY,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YACpD,CAAC;YACD,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC;YACpD,IAAI,CAAC,EAAE,GAAG,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC;YAC/B,IAAI,CAAC,gBAAgB,EAAE,CAAC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AK,CAAC,CAAC;IACvB,CAAC;IAEM,MAAM,CAAC,WAAW,CAAC,GAAW;QACjC,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC,OAAO,CAAC,0CAA0C,CAAC,CAAC,GAAG,CAAC,GAAG,CAAkC,CAAC;QACvH,OAAO,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;IAClC,CAAC;IAEM,MAAM,CAAC,KAAK;QACf,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;YACV,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC;YAChB,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC;QACnB,CAAC;IACL,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Agent Atabey Framework — Internal Branded Types
3
+ * Used to enforce absolute type safety within the core orchestration logic.
4
+ */
5
+ export type Brand<K, T> = K & {
6
+ __brand: T;
7
+ };
8
+ export type TraceID = Brand<string, "TraceID">;
9
+ export type AgentID = Brand<string, "AgentID">;
10
+ export type PhaseID = Brand<string, "PhaseID">;
11
+ export type ProjectPath = Brand<string, "ProjectPath">;
12
+ /**
13
+ * Casts a raw string to a Branded Type.
14
+ * Use this only at the boundaries of the system.
15
+ */
16
+ export declare function asTraceID(val: string): TraceID;
17
+ export declare function asAgentID(val: string): AgentID;
18
+ export declare function asPhaseID(val: string): PhaseID;
19
+ export declare function asProjectPath(val: string): ProjectPath;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Agent Atabey Framework — Internal Branded Types
3
+ * Used to enforce absolute type safety within the core orchestration logic.
4
+ */
5
+ /**
6
+ * Casts a raw string to a Branded Type.
7
+ * Use this only at the boundaries of the system.
8
+ */
9
+ export function asTraceID(val) { return val; }
10
+ export function asAgentID(val) { return val; }
11
+ export function asPhaseID(val) { return val; }
12
+ export function asProjectPath(val) { return val; }
13
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../framework-mcp/src/utils/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,GAAW,IAAa,OAAO,GAAc,CAAC,CAAC,CAAC;AAC1E,MAAM,UAAU,SAAS,CAAC,GAAW,IAAa,OAAO,GAAc,CAAC,CAAC,CAAC;AAC1E,MAAM,UAAU,SAAS,CAAC,GAAW,IAAa,OAAO,GAAc,CAAC,CAAC,CAAC;AAC1E,MAAM,UAAU,aAAa,CAAC,GAAW,IAAiB,OAAO,GAAkB,CAAC,CAAC,CAAC"}
@@ -1,4 +1,4 @@
1
- import { Storage } from "../../../src/shared/storage.js";
1
+ import { Storage } from "../utils/storage.js";
2
2
  /**
3
3
  * [DATA] MCP Resource Definitions
4
4
  */
@@ -43,7 +43,7 @@ export async function handleReadResource(uri) {
43
43
  if (uri === "atabey://memory/project") {
44
44
  const fs = await import("fs");
45
45
  const path = await import("path");
46
- const { getFrameworkDir } = await import("../../../src/cli/utils/memory.js");
46
+ const { getFrameworkDir } = await import("../utils/memory.js");
47
47
  const projectRoot = process.env.ATABEY_PROJECT_ROOT || process.cwd();
48
48
  const fwDir = getFrameworkDir();
49
49
  const p = path.isAbsolute(fwDir)
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Enterprise Base Error class for the Agent Atabey Framework.
3
+ */
4
+ export class AtabeyBaseError extends Error {
5
+ code;
6
+ timestamp;
7
+ details;
8
+ solution;
9
+ constructor(message, code = "ATABEY_INTERNAL_ERROR", details, solution) {
10
+ super(message);
11
+ this.name = this.constructor.name;
12
+ this.code = code;
13
+ this.timestamp = new Date();
14
+ this.details = details;
15
+ this.solution = solution;
16
+ // Ensure proper prototype chain and capture stack trace
17
+ Object.setPrototypeOf(this, new.target.prototype);
18
+ if (Error.captureStackTrace) {
19
+ Error.captureStackTrace(this, this.constructor);
20
+ }
21
+ }
22
+ /**
23
+ * Converts the error into a structured JSON log format.
24
+ */
25
+ toJSON() {
26
+ return {
27
+ name: this.name,
28
+ message: this.message,
29
+ code: this.code,
30
+ timestamp: this.timestamp.toISOString(),
31
+ details: this.details,
32
+ solution: this.solution,
33
+ stack: this.stack,
34
+ };
35
+ }
36
+ }
37
+ /**
38
+ * Thrown when configuration loading or validation fails.
39
+ */
40
+ export class ConfigurationError extends AtabeyBaseError {
41
+ constructor(message, details, solution) {
42
+ super(message, "CONFIGURATION_ERROR", details, solution);
43
+ }
44
+ }
45
+ /**
46
+ * Thrown when data schema or payload validation fails.
47
+ */
48
+ export class ValidationError extends AtabeyBaseError {
49
+ constructor(message, details, solution) {
50
+ super(message, "VALIDATION_ERROR", details, solution);
51
+ }
52
+ }
53
+ /**
54
+ * Thrown when adapter initialization or execution fails.
55
+ */
56
+ export class AdapterError extends AtabeyBaseError {
57
+ constructor(message, adapterId, details, solution) {
58
+ super(`Adapter '${adapterId}' failure: ${message}`, "ADAPTER_ERROR", details, solution);
59
+ }
60
+ }
61
+ /**
62
+ * Thrown when orchestration or agent communication fails.
63
+ */
64
+ export class OrchestrationError extends AtabeyBaseError {
65
+ constructor(message, details, solution) {
66
+ super(message, "ORCHESTRATION_ERROR", details, solution);
67
+ }
68
+ }
@@ -0,0 +1,74 @@
1
+ import fs from "fs";
2
+ import os from "os";
3
+ import path from "path";
4
+ const CWD = process.cwd();
5
+ const HOME = os.homedir();
6
+ const FRAMEWORK = {
7
+ CORE_DIR: ".atabey",
8
+ };
9
+ const FRAMEWORK_DIR_CANDIDATES = [
10
+ ".atabey",
11
+ ".agents",
12
+ ".claude",
13
+ ".gemini",
14
+ ".grok",
15
+ ".cursor",
16
+ ];
17
+ const MCP = {
18
+ TEST_DIR_ENV: "ATABEY_TEST_DIR",
19
+ };
20
+ function findFrameworkDir(basePath) {
21
+ try {
22
+ const pkgPath = path.join(basePath, "package.json");
23
+ if (fs.existsSync(pkgPath)) {
24
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
25
+ if (pkg.atabey && typeof pkg.atabey.frameworkDir === "string") {
26
+ const customDir = path.join(basePath, pkg.atabey.frameworkDir);
27
+ if (fs.existsSync(customDir))
28
+ return customDir;
29
+ }
30
+ }
31
+ }
32
+ catch {
33
+ // ignore
34
+ }
35
+ return null;
36
+ }
37
+ export function isFrameworkDevelopmentRepo() {
38
+ try {
39
+ const pkgPath = path.join(CWD, "package.json");
40
+ if (fs.existsSync(pkgPath)) {
41
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
42
+ if (pkg.name === "atabey") {
43
+ return true;
44
+ }
45
+ }
46
+ }
47
+ catch {
48
+ // ignore
49
+ }
50
+ return false;
51
+ }
52
+ export function getConfigDir() {
53
+ const localDir = findFrameworkDir(CWD);
54
+ if (localDir)
55
+ return localDir;
56
+ // Check for standard local directories if package.json doesn't specify
57
+ const localCandidates = [...FRAMEWORK_DIR_CANDIDATES, ".agent"];
58
+ for (const cand of localCandidates) {
59
+ const p = path.join(CWD, cand);
60
+ if (fs.existsSync(p))
61
+ return p;
62
+ }
63
+ // In dev repo, don't fall back to global dir. Point to local default.
64
+ if (isFrameworkDevelopmentRepo()) {
65
+ return path.join(CWD, FRAMEWORK.CORE_DIR);
66
+ }
67
+ return path.join(HOME, FRAMEWORK.CORE_DIR);
68
+ }
69
+ export function getFrameworkDir() {
70
+ const testDir = process.env[MCP.TEST_DIR_ENV];
71
+ if (testDir)
72
+ return testDir;
73
+ return getConfigDir();
74
+ }
@@ -0,0 +1,207 @@
1
+ import Database from "better-sqlite3";
2
+ import path from "path";
3
+ import fs from "fs";
4
+ import { getFrameworkDir } from "./memory.js";
5
+ /**
6
+ * [DB] Atabey Storage Engine
7
+ * Central SQLite database for enterprise-scale agent state management.
8
+ */
9
+ export class Storage {
10
+ static db = null;
11
+ static getDB() {
12
+ if (!this.db) {
13
+ const frameworkDir = getFrameworkDir();
14
+ if (!fs.existsSync(frameworkDir)) {
15
+ fs.mkdirSync(frameworkDir, { recursive: true });
16
+ }
17
+ const dbPath = path.join(frameworkDir, "atabey.db");
18
+ this.db = new Database(dbPath);
19
+ this.initializeSchema();
20
+ }
21
+ return this.db;
22
+ }
23
+ static initializeSchema() {
24
+ const db = this.db;
25
+ // Agents Table
26
+ db.exec(`
27
+ CREATE TABLE IF NOT EXISTS agents (
28
+ name TEXT PRIMARY KEY,
29
+ state TEXT DEFAULT 'READY',
30
+ task TEXT DEFAULT 'Idle',
31
+ last_updated DATETIME DEFAULT CURRENT_TIMESTAMP
32
+ )
33
+ `);
34
+ // Messages (Hermes) Table
35
+ db.exec(`
36
+ CREATE TABLE IF NOT EXISTS messages (
37
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
38
+ timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
39
+ sender TEXT,
40
+ receiver TEXT,
41
+ category TEXT,
42
+ content TEXT,
43
+ trace_id TEXT,
44
+ parent_id TEXT,
45
+ status TEXT DEFAULT 'PENDING',
46
+ priority TEXT DEFAULT 'NORMAL',
47
+ requires_approval BOOLEAN DEFAULT 0
48
+ )
49
+ `);
50
+ // Tasks Table
51
+ db.exec(`
52
+ CREATE TABLE IF NOT EXISTS tasks (
53
+ id TEXT PRIMARY KEY,
54
+ trace_id TEXT,
55
+ description TEXT,
56
+ agent TEXT,
57
+ status TEXT DEFAULT 'PENDING',
58
+ priority TEXT DEFAULT 'NORMAL',
59
+ dependencies TEXT, -- JSON Array
60
+ created_at DATETIME DEFAULT CURRENT_TIMESTAMP
61
+ )
62
+ `);
63
+ // Logs Table
64
+ db.exec(`
65
+ CREATE TABLE IF NOT EXISTS logs (
66
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
67
+ timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
68
+ agent TEXT,
69
+ action TEXT,
70
+ trace_id TEXT,
71
+ status TEXT,
72
+ summary TEXT,
73
+ findings TEXT
74
+ )
75
+ `);
76
+ // Metadata (State) Table
77
+ db.exec(`
78
+ CREATE TABLE IF NOT EXISTS metadata (
79
+ key TEXT PRIMARY KEY,
80
+ value TEXT
81
+ )
82
+ `);
83
+ }
84
+ // --- Agent Operations ---
85
+ static updateAgentStatus(name, state, task, lastUpdated) {
86
+ const db = this.getDB();
87
+ const cleanName = name.replace("@", "");
88
+ const timestamp = lastUpdated || new Date().toISOString();
89
+ db.prepare(`
90
+ INSERT INTO agents (name, state, task, last_updated)
91
+ VALUES (?, ?, ?, ?)
92
+ ON CONFLICT(name) DO UPDATE SET
93
+ state = excluded.state,
94
+ task = excluded.task,
95
+ last_updated = excluded.last_updated
96
+ `).run(cleanName, state, task, timestamp);
97
+ }
98
+ static getAllAgents() {
99
+ return this.getDB().prepare("SELECT * FROM agents").all();
100
+ }
101
+ // --- Message Operations ---
102
+ static saveMessage(msg) {
103
+ const db = this.getDB();
104
+ db.prepare(`
105
+ INSERT INTO messages (sender, receiver, category, content, trace_id, parent_id, status, priority, requires_approval)
106
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
107
+ `).run(msg.from, msg.to, msg.category, msg.content, msg.traceId, msg.parentId || null, msg.status || "PENDING", msg.priority || "NORMAL", msg.requiresApproval ? 1 : 0);
108
+ }
109
+ static getPendingMessages() {
110
+ const rows = this.getDB().prepare("SELECT * FROM messages WHERE status IN ('PENDING', 'APPROVED') ORDER BY priority DESC, timestamp ASC").all();
111
+ return rows.map(r => ({
112
+ id: r.id,
113
+ timestamp: r.timestamp,
114
+ from: r.sender,
115
+ to: r.receiver,
116
+ category: r.category,
117
+ content: r.content,
118
+ traceId: r.trace_id,
119
+ parentId: r.parent_id || undefined,
120
+ status: r.status,
121
+ priority: r.priority,
122
+ requiresApproval: r.requires_approval === 1
123
+ }));
124
+ }
125
+ static updateMessageStatus(id, status) {
126
+ this.getDB().prepare("UPDATE messages SET status = ? WHERE id = ?").run(status, id);
127
+ }
128
+ // --- Task Operations ---
129
+ static saveTask(task) {
130
+ const db = this.getDB();
131
+ db.prepare(`
132
+ INSERT INTO tasks (id, trace_id, description, agent, status, priority, dependencies)
133
+ VALUES (?, ?, ?, ?, ?, ?, ?)
134
+ ON CONFLICT(id) DO UPDATE SET
135
+ status = excluded.status,
136
+ description = excluded.description
137
+ `).run(task.id, task.traceId, task.description, task.agent, task.status, task.priority, JSON.stringify(task.dependencies || []));
138
+ }
139
+ static getTasks(traceId) {
140
+ const db = this.getDB();
141
+ let rows;
142
+ if (traceId) {
143
+ rows = db.prepare("SELECT * FROM tasks WHERE trace_id = ?").all(traceId);
144
+ }
145
+ else {
146
+ rows = db.prepare("SELECT * FROM tasks").all();
147
+ }
148
+ return rows.map(r => {
149
+ let deps = [];
150
+ try {
151
+ const parsed = JSON.parse(r.dependencies || "[]");
152
+ // Handle cases where dependencies might be double-stringified or are raw JSON strings
153
+ deps = Array.isArray(parsed) ? parsed : JSON.parse(parsed);
154
+ }
155
+ catch {
156
+ // Keep empty array
157
+ }
158
+ return {
159
+ id: r.id,
160
+ traceId: r.trace_id,
161
+ description: r.description,
162
+ agent: r.agent,
163
+ status: r.status,
164
+ priority: r.priority,
165
+ dependencies: deps
166
+ };
167
+ });
168
+ }
169
+ static getLogs(agentName) {
170
+ const db = this.getDB();
171
+ let rows;
172
+ const cleanName = agentName ? agentName.replace("@", "") : undefined;
173
+ if (cleanName) {
174
+ rows = db.prepare("SELECT * FROM logs WHERE agent = ? ORDER BY timestamp DESC").all(cleanName);
175
+ }
176
+ else {
177
+ rows = db.prepare("SELECT * FROM logs ORDER BY timestamp DESC").all();
178
+ }
179
+ return rows.map(r => ({
180
+ id: r.id,
181
+ timestamp: r.timestamp,
182
+ agent: r.agent,
183
+ action: r.action,
184
+ trace_id: r.trace_id || undefined,
185
+ status: r.status,
186
+ summary: r.summary,
187
+ findings: r.findings || undefined
188
+ }));
189
+ }
190
+ // --- Metadata Operations ---
191
+ static setMetadata(key, value) {
192
+ this.getDB().prepare(`
193
+ INSERT INTO metadata (key, value) VALUES (?, ?)
194
+ ON CONFLICT(key) DO UPDATE SET value = excluded.value
195
+ `).run(key, value);
196
+ }
197
+ static getMetadata(key) {
198
+ const row = this.getDB().prepare("SELECT value FROM metadata WHERE key = ?").get(key);
199
+ return row ? row.value : null;
200
+ }
201
+ static reset() {
202
+ if (this.db) {
203
+ this.db.close();
204
+ this.db = null;
205
+ }
206
+ }
207
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Agent Atabey Framework — Internal Branded Types
3
+ * Used to enforce absolute type safety within the core orchestration logic.
4
+ */
5
+ /**
6
+ * Casts a raw string to a Branded Type.
7
+ * Use this only at the boundaries of the system.
8
+ */
9
+ export function asTraceID(val) { return val; }
10
+ export function asAgentID(val) { return val; }
11
+ export function asPhaseID(val) { return val; }
12
+ export function asProjectPath(val) { return val; }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "atabey-mcp",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "description": "Agent Atabey Model Context Protocol (MCP) Server",
5
5
  "author": "Yusuf BEKAR",
6
6
  "license": "MIT",
@@ -26,9 +26,11 @@
26
26
  },
27
27
  "dependencies": {
28
28
  "@modelcontextprotocol/sdk": "^1.26.0",
29
+ "better-sqlite3": "^12.10.1",
29
30
  "zod": "^3.24.2"
30
31
  },
31
32
  "devDependencies": {
33
+ "@types/better-sqlite3": "^7.6.13",
32
34
  "@types/node": "^25.9.1",
33
35
  "typescript": "^5.9.3"
34
36
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "atabey",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "description": "The Supreme AI Governance & Autonomous Orchestration Framework for Enterprise Development. Supports Polyglot Backends (Go, Java, Python, .NET, Node.js) and Multi-Language Communication (TR/EN).",
5
5
  "author": "Yusuf BEKAR",
6
6
  "license": "MIT",
@@ -46,9 +46,11 @@
46
46
  "node": ">=18.0.0"
47
47
  },
48
48
  "scripts": {
49
- "build": "tsc && npm run build --prefix framework-mcp && npm run build:ui",
49
+ "build": "npm run build:core && npm run build:mcp && npm run build:ui",
50
+ "build:core": "tsc",
51
+ "build:mcp": "npm run build --prefix framework-mcp",
50
52
  "build:ui": "npm run build --prefix src/dashboard",
51
- "atabey:build": "npm run build --prefix framework-mcp",
53
+ "atabey:build": "npm run build:mcp",
52
54
  "atabey:test": "vitest run",
53
55
  "atabey:test:watch": "vitest",
54
56
  "atabey:status": "atabey status",
@@ -66,7 +68,7 @@
66
68
  "access": "public"
67
69
  },
68
70
  "dependencies": {
69
- "atabey-mcp": "^0.0.8",
71
+ "atabey-mcp": "^0.0.9",
70
72
  "@modelcontextprotocol/sdk": "^1.29.0",
71
73
  "better-sqlite3": "^12.10.1",
72
74
  "chalk": "^5.6.2",