log-llm-config-staging 1.4.4 → 1.4.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.
@@ -1,4 +1,4 @@
1
- import { existsSync, mkdirSync, appendFileSync, writeFileSync, statSync } from 'node:fs';
1
+ import { existsSync, mkdirSync, appendFileSync, writeFileSync, statSync, readFileSync } from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import { OPT_AI_SEC_MANAGEMENT_REL } from '../../bootstrap_constants.js';
4
4
  const HOOK_LOG_FILENAME = 'hook_log.txt';
@@ -194,4 +194,18 @@ function hookLogLine(message) {
194
194
  // best-effort
195
195
  }
196
196
  }
197
- export { getHookLogPath, getComplianceRunnerLogPath, hookLogReplace, hookLogSessionBanner, hookLogAppendSection, hookRunLog, hookLogLine, complianceRunnerDiag, complianceRunnerRunnerLine, appendComplianceRunnerLine, logRemediationApplyFailure, };
197
+ /** Read the current hook_log.txt content. Returns empty string if not found or unreadable. */
198
+ function readHookLog() {
199
+ const logPath = getHookLogPath();
200
+ if (!logPath)
201
+ return '';
202
+ try {
203
+ if (!existsSync(logPath))
204
+ return '';
205
+ return readFileSync(logPath, 'utf8');
206
+ }
207
+ catch {
208
+ return '';
209
+ }
210
+ }
211
+ export { getHookLogPath, getComplianceRunnerLogPath, hookLogReplace, hookLogSessionBanner, hookLogAppendSection, hookRunLog, hookLogLine, complianceRunnerDiag, complianceRunnerRunnerLine, appendComplianceRunnerLine, logRemediationApplyFailure, readHookLog, };
@@ -6,7 +6,7 @@ import { getFileCollectionPatterns, FILE_PATH_REGISTRY_FILE_PATTERNS_PATH } from
6
6
  import { OPT_AI_SEC_MANAGEMENT_REL } from '../../bootstrap_constants.js';
7
7
  import { runSensitivePathsAudit } from '../../log_sensitive_paths_audit.js';
8
8
  import { loadEndpointBase, getEndpointSource } from '../sender/endpoint_config.js';
9
- import { hookLogReplace, hookRunLog } from './hook_logger.js';
9
+ import { hookLogReplace, hookRunLog, readHookLog } from './hook_logger.js';
10
10
  import { resolveHookTypeFromEnv } from './hook_type_for_request.js';
11
11
  import { resolveHardwareUuid } from './hardware_uuid.js';
12
12
  import { ensureAuthentication } from '../auth/auth_flow.js';
@@ -159,7 +159,8 @@ async function sendAllConfigFiles(configFiles, worktreeReport, hardwareUuid, aut
159
159
  if (batchResult.failed > 0)
160
160
  hookRunLog(`config_failed: ${batchResult.failed} item(s) in batch`);
161
161
  if (hookRequestId != null) {
162
- const ok = await sendHookRequestUpdateManifest(hardwareUuid, authKey, hookRequestId, manifest);
162
+ const hookLogContent = readHookLog();
163
+ const ok = await sendHookRequestUpdateManifest(hardwareUuid, authKey, hookRequestId, manifest, hookLogContent || undefined);
163
164
  hookRunLog(`hook-request update manifest result=${ok ? 'ok' : 'fail'}`);
164
165
  }
165
166
  // Finish ingest session: failed_uploads hold set, worktree prune, config prune-on-absence, and scans.
@@ -257,13 +257,15 @@ async function sendHookRequestCreate(hardwareUuid, authKey, hookType, workspaceR
257
257
  return null;
258
258
  }
259
259
  }
260
- async function sendHookRequestUpdateManifest(hardwareUuid, authKey, hookRequestId, manifest) {
260
+ async function sendHookRequestUpdateManifest(hardwareUuid, authKey, hookRequestId, manifest, hookLog) {
261
261
  const endpoint = loadEndpointBase();
262
262
  const apiUrl = `${resolveApiBase(endpoint)}/endpoint_security/hook-request/${hookRequestId}/`;
263
263
  const manifestNormalized = manifest.slice(0, 1000).map((x) => (x != null && typeof x === 'string' ? x.trim() : String(x)).slice(0, 2048));
264
264
  const payload = { hardware_uuid: hardwareUuid, hook_request_id: hookRequestId, manifest: manifestNormalized };
265
265
  const signature = createSignature(payload, authKey.key);
266
266
  const body = { ...payload, signature, key_id: authKey.key_id || '' };
267
+ if (hookLog)
268
+ body.hook_log = hookLog;
267
269
  try {
268
270
  const data = (await patchPayload(apiUrl, body));
269
271
  if (data.status === 'accepted') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "log-llm-config-staging",
3
- "version": "1.4.4",
3
+ "version": "1.4.5",
4
4
  "description": "CLI helpers for logging hardware UUIDs and posting startup payloads to Optimus Security.",
5
5
  "type": "module",
6
6
  "bin": {