@zeph-to/mcp-server 1.7.0 → 1.9.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/dist/config.d.ts.map +1 -1
- package/dist/config.js +26 -1
- package/package.json +1 -1
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAuCD,eAAO,MAAM,UAAU,QAAO,eA0B7B,CAAC"}
|
package/dist/config.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.loadConfig = void 0;
|
|
4
4
|
const fs_1 = require("fs");
|
|
5
5
|
const crypto_1 = require("crypto");
|
|
6
|
+
const child_process_1 = require("child_process");
|
|
6
7
|
const path_1 = require("path");
|
|
7
8
|
const DEFAULT_BASE_URL = 'https://api.zeph.to/v1';
|
|
8
9
|
const resolvedEnv = (key) => {
|
|
@@ -18,18 +19,42 @@ const loadFileConfig = () => {
|
|
|
18
19
|
return {};
|
|
19
20
|
}
|
|
20
21
|
};
|
|
22
|
+
/** Detect Claude Code session ID from ~/.claude/projects/{projectHash}/{sessionId}/ */
|
|
23
|
+
const detectClaudeSessionId = () => {
|
|
24
|
+
try {
|
|
25
|
+
const projectDir = process.env.CLAUDE_PROJECT_DIR ?? process.cwd();
|
|
26
|
+
const projectHash = projectDir.replace(/\//g, '-').replace(/^-/, '');
|
|
27
|
+
const sessionsDir = (0, path_1.join)(process.env.HOME ?? '~', '.claude', 'projects', projectHash);
|
|
28
|
+
const entries = (0, fs_1.readdirSync)(sessionsDir)
|
|
29
|
+
.filter((name) => /^[0-9a-f]{8}-/.test(name))
|
|
30
|
+
.map((name) => ({ name, mtime: (0, fs_1.statSync)((0, path_1.join)(sessionsDir, name)).mtimeMs }))
|
|
31
|
+
.sort((a, b) => b.mtime - a.mtime);
|
|
32
|
+
return entries[0]?.name;
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
21
38
|
const loadConfig = () => {
|
|
22
39
|
const fileConfig = loadFileConfig();
|
|
23
40
|
const apiKey = resolvedEnv('ZEPH_API_KEY') ?? fileConfig.apiKey;
|
|
24
41
|
if (!apiKey) {
|
|
25
42
|
throw new Error('ZEPH_API_KEY not found. Run "npx @zeph-to/hook-sdk install" or set ZEPH_API_KEY env var.');
|
|
26
43
|
}
|
|
44
|
+
const sessionId = resolvedEnv('ZEPH_SESSION_ID') ?? detectClaudeSessionId() ?? `sess_${(0, crypto_1.randomBytes)(12).toString('base64url')}`;
|
|
45
|
+
// Write sessionId to tmp file so shell hooks (zeph-stop.sh) can read it
|
|
46
|
+
try {
|
|
47
|
+
const projectDir = process.env.CLAUDE_PROJECT_DIR ?? process.cwd();
|
|
48
|
+
const hash = (0, child_process_1.execFileSync)('cksum', { input: projectDir, encoding: 'utf-8' }).split(' ')[0];
|
|
49
|
+
(0, fs_1.writeFileSync)(`/tmp/zeph-session-${hash}`, sessionId);
|
|
50
|
+
}
|
|
51
|
+
catch { /* best-effort */ }
|
|
27
52
|
return {
|
|
28
53
|
apiKey,
|
|
29
54
|
baseUrl: (resolvedEnv('ZEPH_BASE_URL') ?? fileConfig.baseUrl ?? DEFAULT_BASE_URL).replace(/\/$/, ''),
|
|
30
55
|
hookId: resolvedEnv('ZEPH_HOOK_ID') ?? fileConfig.hookId,
|
|
31
56
|
deviceId: resolvedEnv('ZEPH_DEVICE_ID') ?? fileConfig.deviceId,
|
|
32
|
-
sessionId
|
|
57
|
+
sessionId,
|
|
33
58
|
};
|
|
34
59
|
};
|
|
35
60
|
exports.loadConfig = loadConfig;
|