log-llm-config 1.3.54 → 1.3.55
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.
|
@@ -19,7 +19,7 @@ import { loadEndpointBase } from '../sender/endpoint_config.js';
|
|
|
19
19
|
import { resolveHardwareUuid, tryResolveHardwareUuid } from './hardware_uuid.js';
|
|
20
20
|
import { buildDeferredCursorRestartCommand, enforceRemediation, fetchSync, isTrustedRestartCommandForAutofix, remediationFixSpec, reportAutofixApplied, syncRemediations, } from './remediation_sync.js';
|
|
21
21
|
import { sendConfigFile } from '../sender/batch_sender.js';
|
|
22
|
-
import {
|
|
22
|
+
import { ensureAuthentication } from '../auth/auth_flow.js';
|
|
23
23
|
/** Normalize manifest/env/CLI agent tokens to a known Agent, or '' if unrecognized. */
|
|
24
24
|
export function normalizeAgentToken(raw) {
|
|
25
25
|
if (typeof raw !== 'string')
|
|
@@ -187,19 +187,18 @@ function loadRemediationConfigJson(configFilePath, checkSettingPaths = []) {
|
|
|
187
187
|
export function runLocalRemediationComplianceCheck(agent = 'cursor') {
|
|
188
188
|
try {
|
|
189
189
|
const { remediations: rawEntries } = readRemediationInstructionsFile();
|
|
190
|
-
const entries = rawEntries;
|
|
191
|
-
|
|
192
|
-
if (scoped.length === 0) {
|
|
190
|
+
const entries = rawEntries.filter((e) => targetsCurrentAgent(e, agent));
|
|
191
|
+
if (entries.length === 0) {
|
|
193
192
|
hookRunLog('compliance_check: no remediation instructions present');
|
|
194
193
|
return { status: 'ok', checked_at: new Date().toISOString(), manifest_uuids: [], violations: [] };
|
|
195
194
|
}
|
|
196
|
-
const uuids =
|
|
195
|
+
const uuids = entries.map((e) => e.uuid);
|
|
197
196
|
const violations = [];
|
|
198
197
|
let skippedNoCompliance = 0;
|
|
199
198
|
let skippedNonJson = 0;
|
|
200
199
|
let skippedNoChecks = 0;
|
|
201
200
|
let skippedUnreadable = 0;
|
|
202
|
-
for (const entry of
|
|
201
|
+
for (const entry of entries) {
|
|
203
202
|
const compliance = entry.fix ?? entry.compliance;
|
|
204
203
|
if (!compliance) {
|
|
205
204
|
skippedNoCompliance++;
|
|
@@ -387,55 +386,55 @@ export function applyAutofixViolations(violations, agent = 'cursor') {
|
|
|
387
386
|
appliedViolations.push(violation);
|
|
388
387
|
hookRunLog(`autofix: applied uuid=${inst.uuid} path=${configPathForDisk}`);
|
|
389
388
|
reportPromises.push(reportAutofixApplied(inst.uuid, 'success'));
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
389
|
+
if (er.deferredSqlite && configPathForDisk.includes('#')) {
|
|
390
|
+
hookRunLog(`autofix: skip immediate vscdb upload (deferred until after restart) uuid=${inst.uuid}`);
|
|
391
|
+
}
|
|
392
|
+
else {
|
|
393
|
+
let updatedContent;
|
|
394
|
+
if (configPathForDisk.includes('#')) {
|
|
395
|
+
const hi = configPathForDisk.indexOf('#');
|
|
396
|
+
const dbPath = configPathForDisk.slice(0, hi);
|
|
397
|
+
const itemKey = configPathForDisk.slice(hi + 1).trim();
|
|
398
|
+
updatedContent = itemKey ? (readVscdbItemTableJson(dbPath, itemKey) ?? undefined) : undefined;
|
|
394
399
|
}
|
|
395
400
|
else {
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
const hi = configPathForDisk.indexOf('#');
|
|
399
|
-
const dbPath = configPathForDisk.slice(0, hi);
|
|
400
|
-
const itemKey = configPathForDisk.slice(hi + 1).trim();
|
|
401
|
-
updatedContent =
|
|
402
|
-
itemKey ? (readVscdbItemTableJson(dbPath, itemKey) ?? undefined) : undefined;
|
|
401
|
+
try {
|
|
402
|
+
updatedContent = JSON.parse(readFileSync(configPathForDisk, 'utf8'));
|
|
403
403
|
}
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
updatedContent = JSON.parse(readFileSync(configPathForDisk, 'utf8'));
|
|
407
|
-
}
|
|
408
|
-
catch {
|
|
409
|
-
updatedContent = undefined;
|
|
410
|
-
}
|
|
404
|
+
catch {
|
|
405
|
+
updatedContent = undefined;
|
|
411
406
|
}
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
407
|
+
}
|
|
408
|
+
if (updatedContent !== undefined) {
|
|
409
|
+
const fileType = (inst.file_type ?? '').trim();
|
|
410
|
+
if (fileType) {
|
|
411
|
+
const hw = tryResolveHardwareUuid();
|
|
412
|
+
if (hw) {
|
|
413
|
+
// Do not rely on the bulk uploader (start-every-prompt throttles at 1800s).
|
|
414
|
+
// Always attempt to upload the single remediated file immediately.
|
|
415
|
+
reportPromises.push(ensureAuthentication(hw)
|
|
416
|
+
.then((authKey) => sendConfigFile({ file_type: fileType, file_path: configPathForDisk, raw_content: updatedContent }, hw, authKey))
|
|
417
|
+
.then((sentOk) => {
|
|
418
|
+
hookRunLog(`autofix: uploaded remediated file uuid=${inst.uuid} path=${configPathForDisk} ok=${sentOk}`);
|
|
419
|
+
})
|
|
420
|
+
.catch((err) => {
|
|
421
|
+
hookRunLog(`autofix: upload failed uuid=${inst.uuid} path=${configPathForDisk} err=${err instanceof Error ? err.message : String(err)}`);
|
|
422
|
+
}));
|
|
424
423
|
}
|
|
425
424
|
else {
|
|
426
|
-
hookRunLog(`autofix: skip upload uuid=${inst.uuid}
|
|
427
|
-
logRemediationApplyFailure('autofix_post_apply_upload_skipped', {
|
|
428
|
-
uuid: inst.uuid,
|
|
429
|
-
config_file_path: inst.config_file_path,
|
|
430
|
-
reason: 'file_type missing on instruction — server sync/manifest will not see applied file',
|
|
431
|
-
});
|
|
425
|
+
hookRunLog(`autofix: skip upload uuid=${inst.uuid} (hardware UUID unavailable)`);
|
|
432
426
|
}
|
|
433
427
|
}
|
|
428
|
+
else {
|
|
429
|
+
hookRunLog(`autofix: skip upload uuid=${inst.uuid} — remediation_instructions.json missing file_type (re-sync manifest)`);
|
|
430
|
+
logRemediationApplyFailure('autofix_post_apply_upload_skipped', {
|
|
431
|
+
uuid: inst.uuid,
|
|
432
|
+
config_file_path: inst.config_file_path,
|
|
433
|
+
reason: 'file_type missing on instruction — server sync/manifest will not see applied file',
|
|
434
|
+
});
|
|
435
|
+
}
|
|
434
436
|
}
|
|
435
437
|
}
|
|
436
|
-
else {
|
|
437
|
-
hookRunLog(`autofix: skip re-upload uuid=${inst.uuid} (no stored auth key)`);
|
|
438
|
-
}
|
|
439
438
|
const spec = remediationFixSpec(inst);
|
|
440
439
|
if (spec?.restart_required && spec.restart_command) {
|
|
441
440
|
if (!er.deferredSqlite) {
|
|
@@ -565,13 +564,13 @@ export function pruneSatisfiedOneTimeRemediations(agent = 'cursor') {
|
|
|
565
564
|
* a fresh manifest so the gate has up-to-date data when it runs.
|
|
566
565
|
*/
|
|
567
566
|
export async function runComplianceCheck() {
|
|
567
|
+
const agent = currentAgentFromEnv();
|
|
568
568
|
try {
|
|
569
569
|
await syncRemediations(loadEndpointBase(), resolveHardwareUuid());
|
|
570
570
|
}
|
|
571
571
|
catch (err) {
|
|
572
572
|
hookRunLog(`compliance_check: remediation_sync unexpected error: ${err instanceof Error ? err.message : String(err)}`);
|
|
573
573
|
}
|
|
574
|
-
const agent = currentAgentFromEnv();
|
|
575
574
|
const status = runLocalRemediationComplianceCheck(agent);
|
|
576
575
|
if (status.status === 'ok' || status.violations.length === 0) {
|
|
577
576
|
const pruned = pruneSatisfiedOneTimeRemediations(agent);
|