log-llm-config 1.3.67 → 1.3.69

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.
@@ -3,6 +3,9 @@ import { createSignature } from './signing.js';
3
3
  import { loadEndpointBase } from './endpoint_config.js';
4
4
  import { hookRunLog } from '../runtime/hook_logger.js';
5
5
  import { canonicalCursorUserStateVscdbPath } from '../runtime/remediation_config_path.js';
6
+ import fs from 'node:fs';
7
+ import os from 'node:os';
8
+ import path from 'node:path';
6
9
  /** Chunk size per batch request. */
7
10
  export const BATCH_CHUNK_SIZE = 20;
8
11
  const MAX_BATCH_SIZE_BYTES = 500 * 1024; // 500KB
@@ -22,6 +25,17 @@ function estimateConfigFileSize(configFile) {
22
25
  : JSON.stringify(configFile.raw_content || {});
23
26
  return (configFile.file_type?.length || 0) + (configFile.file_path?.length || 0) + contentStr.length + 80 + Math.ceil(contentStr.length * 0.3);
24
27
  }
28
+ function readOrganizationUuid() {
29
+ const envValue = (process.env.OPTIMUS_ORGANIZATION_UUID || '').trim();
30
+ if (envValue)
31
+ return envValue;
32
+ try {
33
+ return fs.readFileSync(path.join(os.homedir(), 'opt-ai-sec', 'management', 'organization-uuid.txt'), 'utf8').trim();
34
+ }
35
+ catch {
36
+ return '';
37
+ }
38
+ }
25
39
  function buildBatchChunks(configFiles, basePayloadSize) {
26
40
  const chunks = [];
27
41
  let currentChunk = [];
@@ -72,7 +86,7 @@ function splitChunk(chunks, chunkIndex) {
72
86
  async function sendConfigFilesBatch(configFiles, hardwareUuid, authKey, hookRequestId, ingestSessionId) {
73
87
  const endpoint = loadEndpointBase();
74
88
  const apiUrl = `${resolveApiBase(endpoint)}/endpoint_security/log-config-files/`;
75
- const metadata = { org_identifier: process.env.GITHUB_ORG || process.env.GH_ORG || '', repo_identifier: process.env.GITHUB_REPOSITORY || process.env.GH_REPOSITORY || '' };
89
+ const metadata = { org_identifier: process.env.GITHUB_ORG || process.env.GH_ORG || '', organization_uuid: readOrganizationUuid(), repo_identifier: process.env.GITHUB_REPOSITORY || process.env.GH_REPOSITORY || '' };
76
90
  const basePayloadSize = JSON.stringify({ hardware_uuid: hardwareUuid, metadata }).length + 800;
77
91
  const chunks = buildBatchChunks(configFiles, basePayloadSize);
78
92
  const totals = { accepted: 0, failed: 0 };
@@ -161,7 +175,7 @@ async function sendConfigFile(configFile, hardwareUuid, authKey) {
161
175
  const uploadPath = canonicalCursorUserStateVscdbPath(configFile.file_path);
162
176
  const payload = { hardware_uuid: hardwareUuid, file_type: configFile.file_type, file_path: uploadPath, raw_content: configFile.raw_content };
163
177
  const signature = createSignature(payload, authKey.key);
164
- const body = { ...payload, signature, key_id: authKey.key_id || '', metadata: { org_identifier: process.env.GITHUB_ORG || process.env.GH_ORG || '', repo_identifier: process.env.GITHUB_REPOSITORY || process.env.GH_REPOSITORY || '' } };
178
+ const body = { ...payload, signature, key_id: authKey.key_id || '', metadata: { org_identifier: process.env.GITHUB_ORG || process.env.GH_ORG || '', organization_uuid: readOrganizationUuid(), repo_identifier: process.env.GITHUB_REPOSITORY || process.env.GH_REPOSITORY || '' } };
165
179
  try {
166
180
  const response = await postStartupPayload(apiUrl, body);
167
181
  if (response.status !== 'accepted') {
@@ -3,6 +3,9 @@ import { classifyEndpointResponse, postStartupPayload } from '../endpoint_client
3
3
  import { resolveHardwareUuid } from './hardware_uuid.js';
4
4
  import { writeAuthKey, readStoredAuthKey, loadEndpointBase, buildStartupEndpointUrl } from './auth_key_store.js';
5
5
  import { resolveUserProfile } from './user_profile.js';
6
+ import fs from 'node:fs';
7
+ import os from 'node:os';
8
+ import path from 'node:path';
6
9
  const canonicalizeValue = (value) => {
7
10
  if (Array.isArray(value))
8
11
  return value.map(canonicalizeValue);
@@ -19,9 +22,21 @@ const createSignature = (payloadSummary, keyHex) => {
19
22
  // Keep this adapter for backward compatibility of public exports in log_uuid.
20
23
  return createSharedSignature(payloadSummary, keyHex);
21
24
  };
25
+ const readOrganizationUuid = () => {
26
+ const envValue = (process.env.OPTIMUS_ORGANIZATION_UUID || '').trim();
27
+ if (envValue)
28
+ return envValue;
29
+ try {
30
+ return fs.readFileSync(path.join(os.homedir(), 'opt-ai-sec', 'management', 'organization-uuid.txt'), 'utf8').trim();
31
+ }
32
+ catch {
33
+ return '';
34
+ }
35
+ };
22
36
  const getMetadata = () => ({
23
37
  github_username: process.env.GITHUB_USER || process.env.GH_USER || '',
24
38
  org_identifier: process.env.GITHUB_ORG || '',
39
+ organization_uuid: readOrganizationUuid(),
25
40
  repo_identifier: process.env.GITHUB_REPOSITORY || '',
26
41
  branch: process.env.GITHUB_REF_NAME || process.env.BRANCH_NAME || '',
27
42
  commit_sha: process.env.GITHUB_SHA || '',
@@ -91,6 +91,19 @@ const readClaudeEmailFromHomeFiles = () => {
91
91
  return '';
92
92
  };
93
93
  const readClaudeAuthEmail = () => readClaudeAuthEmailFromCli().trim() || readClaudeEmailFromHomeFiles();
94
+ const readMachineName = () => {
95
+ const fromEnv = process.env.OPTIMUS_MACHINE_NAME?.trim();
96
+ if (fromEnv)
97
+ return fromEnv;
98
+ // macOS: human-readable computer name set in System Settings
99
+ if (process.platform === 'darwin') {
100
+ const name = readCommandOutput('scutil --get ComputerName');
101
+ if (name)
102
+ return name;
103
+ }
104
+ // Fallback: OS hostname
105
+ return os.hostname();
106
+ };
94
107
  const readMacUsername = () => {
95
108
  const fromEnv = process.env.OPTIMUS_MAC_USERNAME?.trim() ||
96
109
  process.env.USER?.trim() ||
@@ -169,6 +182,7 @@ const buildDefaultUserProfile = () => ({
169
182
  generateduuid: readMacAccountGeneratedUid() || crypto.randomUUID(),
170
183
  machineuuid: resolveHardwareUuid(),
171
184
  mac_username: readMacUsername(),
185
+ machine_name: readMachineName(),
172
186
  github_username: readGithubUsername(),
173
187
  claude_email: readClaudeAuthEmail(),
174
188
  cursor_email: readCursorCachedEmail(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "log-llm-config",
3
- "version": "1.3.67",
3
+ "version": "1.3.69",
4
4
  "description": "CLI helpers for logging hardware UUIDs and posting startup payloads to Optimus Security.",
5
5
  "type": "module",
6
6
  "bin": {