lowdown-proxy 0.1.4 → 0.1.5

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.
@@ -0,0 +1,25 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
3
+ import { homedir } from "node:os";
4
+ import { join } from "node:path";
5
+ export function getNodeId() {
6
+ const dir = join(homedir(), ".lowdown");
7
+ const file = join(dir, "node.json");
8
+ if (existsSync(file)) {
9
+ try {
10
+ const data = JSON.parse(readFileSync(file, "utf-8"));
11
+ if (data.node_id)
12
+ return data.node_id;
13
+ }
14
+ catch {
15
+ // 파일 손상 시 새로 생성
16
+ }
17
+ }
18
+ const identity = {
19
+ node_id: "ld_" + randomUUID().replace(/-/g, "").slice(0, 12),
20
+ created_at: new Date().toISOString(),
21
+ };
22
+ mkdirSync(dir, { recursive: true });
23
+ writeFileSync(file, JSON.stringify(identity, null, 2), "utf-8");
24
+ return identity.node_id;
25
+ }
package/dist/proxy.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { spawn } from "node:child_process";
2
2
  import { createInterface } from "node:readline";
3
3
  import { recordInteraction } from "./supabase.js";
4
+ import { getNodeId } from "./node-identity.js";
4
5
  /**
5
6
  * lowdown-proxy 핵심 로직.
6
7
  *
@@ -10,6 +11,7 @@ import { recordInteraction } from "./supabase.js";
10
11
  * - tool_execution 성공(JSON-RPC 에러 없음)과 실제 결과 품질은 다른 문제 — v0는 전자만 다룬다.
11
12
  */
12
13
  export function runProxy(opts) {
14
+ const nodeId = getNodeId();
13
15
  const child = spawn(opts.command, opts.args, {
14
16
  stdio: ["pipe", "pipe", "inherit"], // stderr는 그대로 상위로 흘려보냄(디버깅용)
15
17
  });
@@ -56,6 +58,7 @@ export function runProxy(opts) {
56
58
  outcome,
57
59
  latency_ms,
58
60
  source: opts.source,
61
+ node_id: nodeId,
59
62
  };
60
63
  // fire-and-forget — 응답 전달을 기다리게 하지 않음
61
64
  void recordInteraction(record);
package/dist/supabase.js CHANGED
@@ -37,6 +37,7 @@ export async function recordInteraction(record) {
37
37
  outcome: record.outcome,
38
38
  latency_ms: record.latency_ms ?? null,
39
39
  source: record.source ?? "organic",
40
+ node_id: record.node_id ?? null,
40
41
  });
41
42
  if (error && process.env.LOWDOWN_DEBUG) {
42
43
  console.error("[lowdown] interaction 기록 실패:", error.message);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lowdown-proxy",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "mcpName": "io.github.PetShopBros/lowdown-proxy",
5
5
  "description": "Record and query AI agent/tool/service interactions. Shared reputation layer for the multi-agent ecosystem.",
6
6
  "type": "module",