@hasna/logs 0.3.13 → 0.3.14

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.
@@ -6,10 +6,10 @@ import {
6
6
  setPageAuth,
7
7
  setRetentionPolicy,
8
8
  startScheduler
9
- } from "../index-2sbhn1ye.js";
9
+ } from "../index-5qwba140.js";
10
10
  import {
11
11
  getHealth
12
- } from "../index-xjn8gam3.js";
12
+ } from "../index-cpvq9np9.js";
13
13
  import {
14
14
  createAlertRule,
15
15
  createPage,
@@ -31,7 +31,7 @@ import {
31
31
  updateAlertRule,
32
32
  updateIssueStatus,
33
33
  updateProject
34
- } from "../index-t97ttm0a.js";
34
+ } from "../index-6zrkek5y.js";
35
35
  import {
36
36
  createJob,
37
37
  deleteJob,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/logs",
3
- "version": "0.3.13",
3
+ "version": "0.3.14",
4
4
  "description": "Log aggregation + browser script + headless page scanner + performance monitoring for AI agents",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -39,6 +39,7 @@
39
39
  "author": "Andrei Hasna <andrei@hasna.com>",
40
40
  "license": "Apache-2.0",
41
41
  "dependencies": {
42
+ "@hasna/cloud": "^0.1.0",
42
43
  "@modelcontextprotocol/sdk": "^1.12.1",
43
44
  "commander": "^14.0.0",
44
45
  "hono": "^4.7.11",
package/src/db/index.ts CHANGED
@@ -1,13 +1,30 @@
1
- import { Database } from "bun:sqlite"
1
+ import { SqliteAdapter as Database } from "@hasna/cloud"
2
2
  import { join } from "node:path"
3
- import { existsSync, mkdirSync } from "node:fs"
3
+ import { existsSync, mkdirSync, cpSync } from "node:fs"
4
4
  import { migrateAlertRules } from "./migrations/001_alert_rules.ts"
5
5
  import { migrateIssues } from "./migrations/002_issues.ts"
6
6
  import { migrateRetention } from "./migrations/003_retention.ts"
7
7
  import { migratePageAuth } from "./migrations/004_page_auth.ts"
8
8
 
9
- const DATA_DIR = process.env.LOGS_DATA_DIR ?? join(process.env.HOME ?? "~", ".logs")
10
- const DB_PATH = process.env.LOGS_DB_PATH ?? join(DATA_DIR, "logs.db")
9
+ function resolveDataDir(): string {
10
+ const explicit = process.env.HASNA_LOGS_DATA_DIR ?? process.env.LOGS_DATA_DIR
11
+ if (explicit) return explicit
12
+
13
+ const home = process.env.HOME ?? "~"
14
+ const newDir = join(home, ".hasna", "logs")
15
+ const oldDir = join(home, ".logs")
16
+
17
+ // Auto-migrate: copy old data to new location if needed
18
+ if (!existsSync(newDir) && existsSync(oldDir)) {
19
+ mkdirSync(join(home, ".hasna"), { recursive: true })
20
+ cpSync(oldDir, newDir, { recursive: true })
21
+ }
22
+
23
+ return newDir
24
+ }
25
+
26
+ const DATA_DIR = resolveDataDir()
27
+ const DB_PATH = process.env.HASNA_LOGS_DB_PATH ?? process.env.LOGS_DB_PATH ?? join(DATA_DIR, "logs.db")
11
28
 
12
29
  let _db: Database | null = null
13
30
 
@@ -18,6 +35,15 @@ export function getDb(): Database {
18
35
  _db.run("PRAGMA journal_mode=WAL")
19
36
  _db.run("PRAGMA foreign_keys=ON")
20
37
  migrate(_db)
38
+ _db.run(`CREATE TABLE IF NOT EXISTS feedback (
39
+ id TEXT PRIMARY KEY DEFAULT (lower(hex(randomblob(16)))),
40
+ message TEXT NOT NULL,
41
+ email TEXT,
42
+ category TEXT DEFAULT 'general',
43
+ version TEXT,
44
+ machine_id TEXT,
45
+ created_at TEXT NOT NULL DEFAULT (datetime('now'))
46
+ )`)
21
47
  return _db
22
48
  }
23
49
 
package/src/lib/health.ts CHANGED
@@ -29,7 +29,7 @@ export function getHealth(db: Database): HealthResult {
29
29
 
30
30
  let db_size_bytes: number | null = null
31
31
  try {
32
- const dbPath = process.env.LOGS_DB_PATH
32
+ const dbPath = process.env.HASNA_LOGS_DB_PATH ?? process.env.LOGS_DB_PATH
33
33
  if (dbPath) {
34
34
  const { statSync } = require("node:fs")
35
35
  db_size_bytes = statSync(dbPath).size
package/src/mcp/index.ts CHANGED
@@ -338,5 +338,26 @@ server.tool("log_stats", {
338
338
  }
339
339
  })
340
340
 
341
+ server.tool(
342
+ "send_feedback",
343
+ "Send feedback about this service",
344
+ {
345
+ message: z.string(),
346
+ email: z.string().optional(),
347
+ category: z.enum(["bug", "feature", "general"]).optional(),
348
+ },
349
+ async (params) => {
350
+ try {
351
+ const pkg = require("../../package.json")
352
+ db.run("INSERT INTO feedback (message, email, category, version) VALUES (?, ?, ?, ?)", [
353
+ params.message, params.email || null, params.category || "general", pkg.version,
354
+ ])
355
+ return { content: [{ type: "text" as const, text: "Feedback saved. Thank you!" }] }
356
+ } catch (e) {
357
+ return { content: [{ type: "text" as const, text: String(e) }], isError: true }
358
+ }
359
+ },
360
+ )
361
+
341
362
  const transport = new StdioServerTransport()
342
363
  await server.connect(transport)