@hasna/logs 0.3.22 → 0.3.23
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/dist/cli/index.js +1 -1
- package/dist/export-yjaar93b.js +10 -0
- package/dist/health-9792c1rc.js +8 -0
- package/dist/health-egdb00st.js +8 -0
- package/dist/{http-1r4r23qf.js → http-0wsh40x1.js} +5 -1
- package/dist/index-14dvwcf1.js +45 -0
- package/dist/index-1f2ghyhm.js +540 -0
- package/dist/{index-2tg9psrh.js → index-2sbhn1ye.js} +2 -2
- package/dist/{index-8pwbytc6.js → index-4ba0sabv.js} +2 -2
- package/dist/{index-sgg59p1t.js → index-4hj4sakk.js} +2 -2
- package/dist/index-5qwba140.js +1241 -0
- package/dist/index-5tvnhvgr.js +536 -0
- package/dist/index-6y8pmes4.js +45 -0
- package/dist/{index-9n6bpjxf.js → index-6zrkek5y.js} +3134 -4467
- package/dist/index-7qhh666n.js +1241 -0
- package/dist/index-86j0hn03.js +540 -0
- package/dist/index-exeq2gs6.js +79 -0
- package/dist/index-fzmz9aqs.js +1241 -0
- package/dist/index-g8dczzvv.js +30 -0
- package/dist/index-rbrsvsyh.js +88 -0
- package/dist/index-t97ttm0a.js +543 -0
- package/dist/{index-hwabsrfh.js → index-vmr85wa1.js} +3146 -4309
- package/dist/index-wbsq8qjd.js +1241 -0
- package/dist/index-xjn8gam3.js +39 -0
- package/dist/index-yb8yd4j6.js +39 -0
- package/dist/{index-ssqkc6nh.js → index-zmayq5kj.js} +1 -1
- package/dist/jobs-02z4fzsn.js +22 -0
- package/dist/mcp/index.js +10 -10
- package/dist/query-6s5gqkck.js +15 -0
- package/dist/query-shjjj67k.js +14 -0
- package/dist/query-tcg3bm9s.js +14 -0
- package/dist/server/index.js +1 -1
- package/package.json +1 -1
- package/sdk/package.json +1 -1
- package/src/mcp/http.test.ts +3 -3
- package/src/mcp/http.ts +8 -1
- package/src/mcp/index.ts +12 -11
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
__require
|
|
4
|
+
} from "./index-re3ntm60.js";
|
|
5
|
+
|
|
6
|
+
// src/lib/health.ts
|
|
7
|
+
var startTime = Date.now();
|
|
8
|
+
function getHealth(db) {
|
|
9
|
+
const projects = db.prepare("SELECT COUNT(*) as c FROM projects").get().c;
|
|
10
|
+
const total_logs = db.prepare("SELECT COUNT(*) as c FROM logs").get().c;
|
|
11
|
+
const scheduler_jobs = db.prepare("SELECT COUNT(*) as c FROM scan_jobs WHERE enabled = 1").get().c;
|
|
12
|
+
const open_issues = db.prepare("SELECT COUNT(*) as c FROM issues WHERE status = 'open'").get().c;
|
|
13
|
+
const levelRows = db.prepare("SELECT level, COUNT(*) as c FROM logs GROUP BY level").all();
|
|
14
|
+
const logs_by_level = Object.fromEntries(levelRows.map((r) => [r.level, r.c]));
|
|
15
|
+
const oldest = db.prepare("SELECT MIN(timestamp) as t FROM logs").get();
|
|
16
|
+
const newest = db.prepare("SELECT MAX(timestamp) as t FROM logs").get();
|
|
17
|
+
let db_size_bytes = null;
|
|
18
|
+
try {
|
|
19
|
+
const dbPath = process.env.LOGS_DB_PATH;
|
|
20
|
+
if (dbPath) {
|
|
21
|
+
const { statSync } = __require("fs");
|
|
22
|
+
db_size_bytes = statSync(dbPath).size;
|
|
23
|
+
}
|
|
24
|
+
} catch {}
|
|
25
|
+
return {
|
|
26
|
+
status: "ok",
|
|
27
|
+
uptime_seconds: Math.floor((Date.now() - startTime) / 1000),
|
|
28
|
+
db_size_bytes,
|
|
29
|
+
projects,
|
|
30
|
+
total_logs,
|
|
31
|
+
logs_by_level,
|
|
32
|
+
oldest_log: oldest.t,
|
|
33
|
+
newest_log: newest.t,
|
|
34
|
+
scheduler_jobs,
|
|
35
|
+
open_issues
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { getHealth };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
__require
|
|
4
|
+
} from "./index-g8dczzvv.js";
|
|
5
|
+
|
|
6
|
+
// src/lib/health.ts
|
|
7
|
+
var startTime = Date.now();
|
|
8
|
+
function getHealth(db) {
|
|
9
|
+
const projects = db.prepare("SELECT COUNT(*) as c FROM projects").get().c;
|
|
10
|
+
const total_logs = db.prepare("SELECT COUNT(*) as c FROM logs").get().c;
|
|
11
|
+
const scheduler_jobs = db.prepare("SELECT COUNT(*) as c FROM scan_jobs WHERE enabled = 1").get().c;
|
|
12
|
+
const open_issues = db.prepare("SELECT COUNT(*) as c FROM issues WHERE status = 'open'").get().c;
|
|
13
|
+
const levelRows = db.prepare("SELECT level, COUNT(*) as c FROM logs GROUP BY level").all();
|
|
14
|
+
const logs_by_level = Object.fromEntries(levelRows.map((r) => [r.level, r.c]));
|
|
15
|
+
const oldest = db.prepare("SELECT MIN(timestamp) as t FROM logs").get();
|
|
16
|
+
const newest = db.prepare("SELECT MAX(timestamp) as t FROM logs").get();
|
|
17
|
+
let db_size_bytes = null;
|
|
18
|
+
try {
|
|
19
|
+
const dbPath = process.env.LOGS_DB_PATH;
|
|
20
|
+
if (dbPath) {
|
|
21
|
+
const { statSync } = __require("fs");
|
|
22
|
+
db_size_bytes = statSync(dbPath).size;
|
|
23
|
+
}
|
|
24
|
+
} catch {}
|
|
25
|
+
return {
|
|
26
|
+
status: "ok",
|
|
27
|
+
uptime_seconds: Math.floor((Date.now() - startTime) / 1000),
|
|
28
|
+
db_size_bytes,
|
|
29
|
+
projects,
|
|
30
|
+
total_logs,
|
|
31
|
+
logs_by_level,
|
|
32
|
+
oldest_log: oldest.t,
|
|
33
|
+
newest_log: newest.t,
|
|
34
|
+
scheduler_jobs,
|
|
35
|
+
open_issues
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { getHealth };
|
|
@@ -894,7 +894,7 @@ var require_scheduled_task = __commonJS((exports, module) => {
|
|
|
894
894
|
|
|
895
895
|
// node_modules/node-cron/src/background-scheduled-task/index.js
|
|
896
896
|
var require_background_scheduled_task = __commonJS((exports, module) => {
|
|
897
|
-
var __dirname = "/
|
|
897
|
+
var __dirname = "/Users/hasna/Workspace/hasna/opensource/open-logs/node_modules/node-cron/src/background-scheduled-task";
|
|
898
898
|
var EventEmitter = __require("events");
|
|
899
899
|
var path = __require("path");
|
|
900
900
|
var { fork } = __require("child_process");
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
createJob,
|
|
4
|
+
createScanRun,
|
|
5
|
+
deleteJob,
|
|
6
|
+
finishScanRun,
|
|
7
|
+
getJob,
|
|
8
|
+
listJobs,
|
|
9
|
+
listScanRuns,
|
|
10
|
+
updateJob
|
|
11
|
+
} from "./index-3dr7d80h.js";
|
|
12
|
+
import"./index-g8dczzvv.js";
|
|
13
|
+
export {
|
|
14
|
+
updateJob,
|
|
15
|
+
listScanRuns,
|
|
16
|
+
listJobs,
|
|
17
|
+
getJob,
|
|
18
|
+
finishScanRun,
|
|
19
|
+
deleteJob,
|
|
20
|
+
createScanRun,
|
|
21
|
+
createJob
|
|
22
|
+
};
|
package/dist/mcp/index.js
CHANGED
|
@@ -18541,18 +18541,18 @@ function buildServer() {
|
|
|
18541
18541
|
return server;
|
|
18542
18542
|
}
|
|
18543
18543
|
async function main() {
|
|
18544
|
-
const {
|
|
18545
|
-
if (
|
|
18546
|
-
const
|
|
18547
|
-
|
|
18548
|
-
|
|
18549
|
-
process.on("SIGINT", () => void handle.close().finally(() => process.exit(0)));
|
|
18550
|
-
process.on("SIGTERM", () => void handle.close().finally(() => process.exit(0)));
|
|
18544
|
+
const { isStdioMode, resolveMcpHttpPort, startMcpHttpServer } = await import("../http-0wsh40x1.js");
|
|
18545
|
+
if (isStdioMode()) {
|
|
18546
|
+
const server = buildServer();
|
|
18547
|
+
const transport = new StdioServerTransport;
|
|
18548
|
+
await server.connect(transport);
|
|
18551
18549
|
return;
|
|
18552
18550
|
}
|
|
18553
|
-
const
|
|
18554
|
-
|
|
18555
|
-
|
|
18551
|
+
const handle = await startMcpHttpServer(buildServer, {
|
|
18552
|
+
port: resolveMcpHttpPort()
|
|
18553
|
+
});
|
|
18554
|
+
process.on("SIGINT", () => void handle.close().finally(() => process.exit(0)));
|
|
18555
|
+
process.on("SIGTERM", () => void handle.close().finally(() => process.exit(0)));
|
|
18556
18556
|
}
|
|
18557
18557
|
if (import.meta.main) {
|
|
18558
18558
|
main().catch((err) => {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
getLogContext,
|
|
4
|
+
getLogContextFromId,
|
|
5
|
+
searchLogs,
|
|
6
|
+
tailLogs
|
|
7
|
+
} from "./index-exeq2gs6.js";
|
|
8
|
+
import"./index-997bkzr2.js";
|
|
9
|
+
import"./index-re3ntm60.js";
|
|
10
|
+
export {
|
|
11
|
+
tailLogs,
|
|
12
|
+
searchLogs,
|
|
13
|
+
getLogContextFromId,
|
|
14
|
+
getLogContext
|
|
15
|
+
};
|
package/dist/server/index.js
CHANGED
package/package.json
CHANGED
package/sdk/package.json
CHANGED
package/src/mcp/http.test.ts
CHANGED
|
@@ -11,9 +11,9 @@ import {
|
|
|
11
11
|
} from "./http.ts";
|
|
12
12
|
|
|
13
13
|
describe("logs MCP HTTP transport", () => {
|
|
14
|
-
test("defaults port to
|
|
15
|
-
expect(DEFAULT_MCP_HTTP_PORT).toBe(
|
|
16
|
-
expect(resolveMcpHttpPort(["node"], {})).toBe(
|
|
14
|
+
test("defaults port to 8864", () => {
|
|
15
|
+
expect(DEFAULT_MCP_HTTP_PORT).toBe(8864);
|
|
16
|
+
expect(resolveMcpHttpPort(["node"], {})).toBe(8864);
|
|
17
17
|
expect(resolveMcpHttpPort(["node", "--port", "9001"], {})).toBe(9001);
|
|
18
18
|
expect(resolveMcpHttpPort(["node"], { MCP_HTTP_PORT: "9002" })).toBe(9002);
|
|
19
19
|
});
|
package/src/mcp/http.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/
|
|
|
3
3
|
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
4
4
|
|
|
5
5
|
export const MCP_HTTP_SERVICE_NAME = "logs";
|
|
6
|
-
export const DEFAULT_MCP_HTTP_PORT =
|
|
6
|
+
export const DEFAULT_MCP_HTTP_PORT = 8864;
|
|
7
7
|
|
|
8
8
|
export function isHttpMode(
|
|
9
9
|
argv: string[] = process.argv,
|
|
@@ -12,6 +12,13 @@ export function isHttpMode(
|
|
|
12
12
|
return argv.includes("--http") || env.MCP_HTTP === "1";
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
export function isStdioMode(
|
|
16
|
+
argv: string[] = process.argv,
|
|
17
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
18
|
+
): boolean {
|
|
19
|
+
return argv.includes("--stdio") || env.MCP_STDIO === "1";
|
|
20
|
+
}
|
|
21
|
+
|
|
15
22
|
export function resolveMcpHttpPort(
|
|
16
23
|
argv: string[] = process.argv,
|
|
17
24
|
env: NodeJS.ProcessEnv = process.env,
|
package/src/mcp/index.ts
CHANGED
|
@@ -419,20 +419,21 @@ server.tool("list_agents", "List all registered agents.", {}, async () => {
|
|
|
419
419
|
}
|
|
420
420
|
|
|
421
421
|
async function main(): Promise<void> {
|
|
422
|
-
const {
|
|
423
|
-
|
|
424
|
-
if (
|
|
425
|
-
const
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
process.on("SIGINT", () => void handle.close().finally(() => process.exit(0)))
|
|
429
|
-
process.on("SIGTERM", () => void handle.close().finally(() => process.exit(0)))
|
|
422
|
+
const { isStdioMode, resolveMcpHttpPort, startMcpHttpServer } = await import("./http.ts")
|
|
423
|
+
|
|
424
|
+
if (isStdioMode()) {
|
|
425
|
+
const server = buildServer()
|
|
426
|
+
const transport = new StdioServerTransport()
|
|
427
|
+
await server.connect(transport)
|
|
430
428
|
return
|
|
431
429
|
}
|
|
432
430
|
|
|
433
|
-
|
|
434
|
-
const
|
|
435
|
-
|
|
431
|
+
// Default: shared Streamable HTTP server (one process per MCP, many agents).
|
|
432
|
+
const handle = await startMcpHttpServer(buildServer, {
|
|
433
|
+
port: resolveMcpHttpPort(),
|
|
434
|
+
})
|
|
435
|
+
process.on("SIGINT", () => void handle.close().finally(() => process.exit(0)))
|
|
436
|
+
process.on("SIGTERM", () => void handle.close().finally(() => process.exit(0)))
|
|
436
437
|
}
|
|
437
438
|
|
|
438
439
|
if (import.meta.main) {
|