tana-mcp-codemode 0.2.2 → 0.3.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.
- package/README.md +71 -259
- package/dist/entry-node.js +1364 -0
- package/package.json +28 -26
- package/src/api/tana.ts +230 -34
- package/src/compat/bun.ts +39 -0
- package/src/compat/index.ts +29 -0
- package/src/compat/node.ts +62 -0
- package/src/compat/types.ts +15 -0
- package/src/debug-server.ts +232 -0
- package/src/entry-bun.ts +11 -0
- package/src/entry-node.ts +11 -0
- package/src/index.ts +5 -162
- package/src/main.ts +146 -0
- package/src/prompts.ts +2 -1
- package/src/sandbox/executor.ts +4 -2
- package/src/sandbox/workflow.ts +4 -4
- package/src/storage/history.ts +11 -11
package/src/storage/history.ts
CHANGED
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
* Configure database location via TANA_HISTORY_PATH env var.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import {
|
|
11
|
+
import { createDatabase, type CompatDatabase } from "../compat";
|
|
12
12
|
import { homedir } from "os";
|
|
13
13
|
import { join, dirname } from "path";
|
|
14
14
|
import { mkdirSync, existsSync } from "fs";
|
|
15
15
|
import type { ScriptRun } from "../types";
|
|
16
16
|
|
|
17
|
-
let db:
|
|
17
|
+
let db: CompatDatabase | null = null;
|
|
18
18
|
|
|
19
19
|
function getDbPath(): string {
|
|
20
20
|
// Allow custom path via env var
|
|
@@ -46,7 +46,7 @@ function getDbPath(): string {
|
|
|
46
46
|
return join(baseDir, "history.db");
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
function migrateDb(database:
|
|
49
|
+
function migrateDb(database: CompatDatabase): void {
|
|
50
50
|
// Get existing columns
|
|
51
51
|
const columns = database
|
|
52
52
|
.prepare("PRAGMA table_info(script_runs)")
|
|
@@ -63,18 +63,18 @@ function migrateDb(database: Database): void {
|
|
|
63
63
|
|
|
64
64
|
for (const col of newColumns) {
|
|
65
65
|
if (!columnNames.has(col.name)) {
|
|
66
|
-
database.
|
|
66
|
+
database.exec(`ALTER TABLE script_runs ADD COLUMN ${col.name} ${col.type}`);
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
export function initDb():
|
|
71
|
+
export function initDb(): CompatDatabase {
|
|
72
72
|
if (db) return db;
|
|
73
73
|
|
|
74
74
|
const dbPath = getDbPath();
|
|
75
|
-
db =
|
|
75
|
+
db = createDatabase(dbPath);
|
|
76
76
|
|
|
77
|
-
db.
|
|
77
|
+
db.exec(`
|
|
78
78
|
CREATE TABLE IF NOT EXISTS script_runs (
|
|
79
79
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
80
80
|
timestamp INTEGER NOT NULL,
|
|
@@ -94,22 +94,22 @@ export function initDb(): Database {
|
|
|
94
94
|
// Migrate existing databases
|
|
95
95
|
migrateDb(db);
|
|
96
96
|
|
|
97
|
-
db.
|
|
97
|
+
db.exec(`
|
|
98
98
|
CREATE INDEX IF NOT EXISTS idx_script_runs_timestamp
|
|
99
99
|
ON script_runs(timestamp DESC)
|
|
100
100
|
`);
|
|
101
101
|
|
|
102
|
-
db.
|
|
102
|
+
db.exec(`
|
|
103
103
|
CREATE INDEX IF NOT EXISTS idx_script_runs_session
|
|
104
104
|
ON script_runs(session_id)
|
|
105
105
|
`);
|
|
106
106
|
|
|
107
|
-
db.
|
|
107
|
+
db.exec(`
|
|
108
108
|
CREATE INDEX IF NOT EXISTS idx_script_runs_workspace
|
|
109
109
|
ON script_runs(workspace_id)
|
|
110
110
|
`);
|
|
111
111
|
|
|
112
|
-
return db
|
|
112
|
+
return db!;
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
export interface SaveScriptRunOptions {
|