log-llm-config 1.3.65 → 1.3.68

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 || '',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "log-llm-config",
3
- "version": "1.3.65",
3
+ "version": "1.3.68",
4
4
  "description": "CLI helpers for logging hardware UUIDs and posting startup payloads to Optimus Security.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -57,6 +57,6 @@
57
57
  "dependencies": {
58
58
  "axios": "^1.15.2",
59
59
  "canonicalize": "^2.1.0",
60
- "optimus-tofu": "^0.1.14"
60
+ "optimus-tofu": "^0.1.15"
61
61
  }
62
62
  }