log-llm-config 1.3.30 → 1.3.31

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.
@@ -365,7 +365,7 @@ function assertSafeSqliteIdentifiersForItemTable(table, keyColumn, valueColumn)
365
365
  const TRUSTED_CURSOR_SQLITE_DEFERRED_RESTART_COMMAND = 'REPO_ROOT=$(git rev-parse --show-toplevel 2>/dev/null || pwd) && export REPO_ROOT && ' +
366
366
  'CURSOR_PROJECT="${CURSOR_PROJECT_DIR:-$REPO_ROOT}" && export CURSOR_PROJECT && ' +
367
367
  'OPTIMUS_DEFERRED_LOG="${HOME}/opt-ai-sec/management/deferred_vscdb_restart.log" && mkdir -p "$(dirname "$OPTIMUS_DEFERRED_LOG")" && export OPTIMUS_DEFERRED_LOG && ' +
368
- "nohup bash -c 'exec >>\"\$OPTIMUS_DEFERRED_LOG\" 2>&1; echo deferred_restart:begin ts=\$(date -u +%Y-%m-%dT%H:%M:%SZ) REPO_ROOT=\"\$REPO_ROOT\" CURSOR_PROJECT=\"\$CURSOR_PROJECT\"; sleep 2; if [ -f \"\$REPO_ROOT/npx_packages/log-llm-config/dist/apply_deferred_vscdb.js\" ]; then echo deferred_restart:apply_via_monorepo_node; node \"\$REPO_ROOT/npx_packages/log-llm-config/dist/apply_deferred_vscdb.js\"; APPLY_EC=\$?; else echo deferred_restart:apply_via_npx; cd \"\$REPO_ROOT\" && npx --yes log-llm-config@latest apply-deferred-vscdb; APPLY_EC=\$?; fi; echo deferred_restart:apply_exit=\$APPLY_EC; if [ \$APPLY_EC -ne 0 ]; then echo deferred_restart:APPLY_FAILED_see_messages_above; fi; echo deferred_restart:open_cursor; open -a Cursor \"\$CURSOR_PROJECT\"; echo deferred_restart:open_exit=\$?; echo deferred_restart:end ts=\$(date -u +%Y-%m-%dT%H:%M:%SZ)' >/dev/null 2>&1 & killall -9 Cursor";
368
+ "nohup bash -c 'exec >>\"\$OPTIMUS_DEFERRED_LOG\" 2>&1; echo deferred_restart:begin ts=\$(date -u +%Y-%m-%dT%H:%M:%SZ) REPO_ROOT=\"\$REPO_ROOT\" CURSOR_PROJECT=\"\$CURSOR_PROJECT\"; sleep 2; if [ -f \"\$REPO_ROOT/dev_npx_packages/log-llm-config/dist/apply_deferred_vscdb.js\" ]; then echo deferred_restart:apply_via_monorepo_node; node \"\$REPO_ROOT/dev_npx_packages/log-llm-config/dist/apply_deferred_vscdb.js\"; APPLY_EC=\$?; else echo deferred_restart:apply_via_npx; cd \"\$REPO_ROOT\" && npx --yes log-llm-config@latest apply-deferred-vscdb; APPLY_EC=\$?; fi; echo deferred_restart:apply_exit=\$APPLY_EC; if [ \$APPLY_EC -ne 0 ]; then echo deferred_restart:APPLY_FAILED_see_messages_above; fi; echo deferred_restart:open_cursor; open -a Cursor \"\$CURSOR_PROJECT\"; echo deferred_restart:open_exit=\$?; echo deferred_restart:end ts=\$(date -u +%Y-%m-%dT%H:%M:%SZ)' >/dev/null 2>&1 & killall -9 Cursor";
369
369
  const TRUSTED_CURSOR_JSON_SETTINGS_RESTART_COMMAND = 'CURSOR_PROJECT=$(git rev-parse --show-toplevel 2>/dev/null || pwd) && export CURSOR_PROJECT && nohup bash -c \'sleep 2 && open -a Cursor "$CURSOR_PROJECT"\' >/dev/null 2>&1 & killall -9 Cursor';
370
370
  const TRUSTED_CLAUDE_RESTART_COMMAND = "nohup bash -c 'sleep 2 && open -a Claude' >/dev/null 2>&1 & pkill -x 'Claude'";
371
371
  /**
@@ -809,7 +809,7 @@ export async function applyDeferredVscdbFromDisk() {
809
809
  */
810
810
  export function buildDeferredCursorRestartCommand() {
811
811
  // Prefer monorepo path when hooks run from optimus-secure-fdn; otherwise `npx --yes log-llm-config@latest apply-deferred-vscdb`
812
- // (package bin) so published installs work without a local npx_packages copy.
812
+ // (package bin) so published installs work without a local dev_npx_packages copy.
813
813
  return TRUSTED_CURSOR_SQLITE_DEFERRED_RESTART_COMMAND;
814
814
  }
815
815
  function sqliteRowGroupKey(dbPath, op) {
@@ -0,0 +1,85 @@
1
+ import { execFileSync } from 'node:child_process';
2
+ import crypto from 'node:crypto';
3
+ import fs from 'node:fs';
4
+ import os from 'node:os';
5
+ import path from 'node:path';
6
+ import { readCommandOutput, resolveHardwareUuid } from './hardware_uuid.js';
7
+ const safeJsonParse = (raw) => {
8
+ try {
9
+ return JSON.parse(raw);
10
+ }
11
+ catch {
12
+ return null;
13
+ }
14
+ };
15
+ const readCursorCachedEmail = () => {
16
+ const dbPath = path.join(os.homedir(), 'Library/Application Support/Cursor/User/globalStorage/state.vscdb');
17
+ if (!fs.existsSync(dbPath))
18
+ return '';
19
+ try {
20
+ const out = execFileSync('sqlite3', [dbPath, "select value from ItemTable where key='cursorAuth/cachedEmail';"], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim();
21
+ return out;
22
+ }
23
+ catch {
24
+ return '';
25
+ }
26
+ };
27
+ const readClaudeAuthEmail = () => {
28
+ try {
29
+ const out = execFileSync('claude', ['auth', 'status'], {
30
+ encoding: 'utf8',
31
+ stdio: ['ignore', 'pipe', 'ignore'],
32
+ }).trim();
33
+ if (!out)
34
+ return '';
35
+ const parsed = safeJsonParse(out);
36
+ if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {
37
+ const email = parsed.email;
38
+ return typeof email === 'string' ? email : '';
39
+ }
40
+ }
41
+ catch {
42
+ return '';
43
+ }
44
+ return '';
45
+ };
46
+ const readMacUsername = () => {
47
+ const fromEnv = process.env.OPTIMUS_MAC_USERNAME?.trim() ||
48
+ process.env.USER?.trim() ||
49
+ process.env.LOGNAME?.trim() ||
50
+ '';
51
+ if (fromEnv)
52
+ return fromEnv;
53
+ return readCommandOutput('id -un');
54
+ };
55
+ const readGithubUsername = () => {
56
+ return (process.env.GITHUB_USER?.trim() ||
57
+ process.env.GH_USER?.trim() ||
58
+ readCommandOutput('git config user.name'));
59
+ };
60
+ const readUserProfileFromEnvOrFile = () => {
61
+ const inline = process.env.OPTIMUS_USER_PROFILE_JSON?.trim();
62
+ if (inline) {
63
+ const parsed = safeJsonParse(inline);
64
+ if (parsed && typeof parsed === 'object' && !Array.isArray(parsed))
65
+ return parsed;
66
+ }
67
+ const filePath = process.env.OPTIMUS_USER_PROFILE_FILE?.trim();
68
+ if (filePath && fs.existsSync(filePath)) {
69
+ const parsed = safeJsonParse(fs.readFileSync(filePath, { encoding: 'utf8' }));
70
+ if (parsed && typeof parsed === 'object' && !Array.isArray(parsed))
71
+ return parsed;
72
+ }
73
+ return null;
74
+ };
75
+ const buildDefaultUserProfile = () => ({
76
+ generateduuid: crypto.randomUUID(),
77
+ machineuuid: resolveHardwareUuid(),
78
+ mac_username: readMacUsername(),
79
+ github_username: readGithubUsername(),
80
+ claude_email: readClaudeAuthEmail(),
81
+ cursor_email: readCursorCachedEmail(),
82
+ });
83
+ /** Best-effort local user profile object for startup metadata. */
84
+ const resolveUserProfile = () => readUserProfileFromEnvOrFile() ?? buildDefaultUserProfile();
85
+ export { resolveUserProfile };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "log-llm-config",
3
- "version": "1.3.30",
3
+ "version": "1.3.31",
4
4
  "description": "CLI helpers for logging hardware UUIDs and posting startup payloads to Optimus Security.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -33,12 +33,12 @@
33
33
  "repository": {
34
34
  "type": "git",
35
35
  "url": "git+https://github.com/optimuslabs-io/optimus-secure-fdn.git",
36
- "directory": "npx_packages/log-llm-config"
36
+ "directory": "dev_npx_packages/log-llm-config"
37
37
  },
38
38
  "bugs": {
39
39
  "url": "https://github.com/optimuslabs-io/optimus-secure-fdn/issues"
40
40
  },
41
- "homepage": "https://github.com/optimuslabs-io/optimus-secure-fdn/tree/main/npx_packages/log-llm-config#readme",
41
+ "homepage": "https://github.com/optimuslabs-io/optimus-secure-fdn/tree/main/dev_npx_packages/log-llm-config#readme",
42
42
  "files": [
43
43
  "dist/**/*",
44
44
  "README.md"