log-llm-config-staging 1.3.54 → 1.3.56
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.
|
@@ -24,5 +24,7 @@ export function isThisCliModule(argv1, thisImportMetaUrl) {
|
|
|
24
24
|
return false;
|
|
25
25
|
const entry = normalizedCliScriptBasename(argv1);
|
|
26
26
|
const self = normalizedCliScriptBasename(thisImportMetaUrl);
|
|
27
|
-
|
|
27
|
+
if (entry === '' || self === '')
|
|
28
|
+
return false;
|
|
29
|
+
return entry === self || entry === `${self}_staging`;
|
|
28
30
|
}
|
|
@@ -8,10 +8,9 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { applyAutofixViolations, normalizeAgentToken, pruneSatisfiedOneTimeRemediations, runLocalRemediationComplianceCheck, } from './log_config_files/runtime/compliance_check.js';
|
|
10
10
|
import { existsSync, statSync } from 'node:fs';
|
|
11
|
-
import { fileURLToPath } from 'node:url';
|
|
12
|
-
import { basename } from 'node:path';
|
|
13
11
|
import { getRemediationInstructionsPath } from './log_config_files/runtime/management_storage.js';
|
|
14
12
|
import { hookLogSessionBanner, hookRunLog, logRemediationApplyFailure } from './log_config_files/runtime/hook_logger.js';
|
|
13
|
+
import { isThisCliModule } from './cli_invocation_match.js';
|
|
15
14
|
const MANIFEST_STALE_MS = 7 * 24 * 60 * 60 * 1000;
|
|
16
15
|
function parseIde() {
|
|
17
16
|
const eq = process.argv.find((a) => a.startsWith('--ide='));
|
|
@@ -74,14 +73,7 @@ function getManifestStalenessMs() {
|
|
|
74
73
|
}
|
|
75
74
|
}
|
|
76
75
|
function isRunAsCliModule() {
|
|
77
|
-
|
|
78
|
-
if (!entry)
|
|
79
|
-
return false;
|
|
80
|
-
// Compare by basename only: npx bins are symlinks (no .js extension) while import.meta.url
|
|
81
|
-
// is the real resolved path with extension — full-path comparison reliably fails across setups.
|
|
82
|
-
const entryBase = basename(entry).replace(/\.[cm]?js$/, '');
|
|
83
|
-
const selfBase = basename(fileURLToPath(import.meta.url)).replace(/\.[cm]?js$/, '');
|
|
84
|
-
return entryBase !== '' && entryBase === selfBase;
|
|
76
|
+
return isThisCliModule(process.argv[1], import.meta.url);
|
|
85
77
|
}
|
|
86
78
|
/** Short line for success dialog: finding title/sentence from manifest, not per-check remediation technical text. */
|
|
87
79
|
function autofixDialogLine(v) {
|
|
@@ -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')
|
|
@@ -386,55 +386,55 @@ export function applyAutofixViolations(violations, agent = 'cursor') {
|
|
|
386
386
|
appliedViolations.push(violation);
|
|
387
387
|
hookRunLog(`autofix: applied uuid=${inst.uuid} path=${configPathForDisk}`);
|
|
388
388
|
reportPromises.push(reportAutofixApplied(inst.uuid, 'success'));
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
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;
|
|
393
399
|
}
|
|
394
400
|
else {
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
const hi = configPathForDisk.indexOf('#');
|
|
398
|
-
const dbPath = configPathForDisk.slice(0, hi);
|
|
399
|
-
const itemKey = configPathForDisk.slice(hi + 1).trim();
|
|
400
|
-
updatedContent =
|
|
401
|
-
itemKey ? (readVscdbItemTableJson(dbPath, itemKey) ?? undefined) : undefined;
|
|
401
|
+
try {
|
|
402
|
+
updatedContent = JSON.parse(readFileSync(configPathForDisk, 'utf8'));
|
|
402
403
|
}
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
updatedContent = JSON.parse(readFileSync(configPathForDisk, 'utf8'));
|
|
406
|
-
}
|
|
407
|
-
catch {
|
|
408
|
-
updatedContent = undefined;
|
|
409
|
-
}
|
|
404
|
+
catch {
|
|
405
|
+
updatedContent = undefined;
|
|
410
406
|
}
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
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
|
+
}));
|
|
423
423
|
}
|
|
424
424
|
else {
|
|
425
|
-
hookRunLog(`autofix: skip upload uuid=${inst.uuid}
|
|
426
|
-
logRemediationApplyFailure('autofix_post_apply_upload_skipped', {
|
|
427
|
-
uuid: inst.uuid,
|
|
428
|
-
config_file_path: inst.config_file_path,
|
|
429
|
-
reason: 'file_type missing on instruction — server sync/manifest will not see applied file',
|
|
430
|
-
});
|
|
425
|
+
hookRunLog(`autofix: skip upload uuid=${inst.uuid} (hardware UUID unavailable)`);
|
|
431
426
|
}
|
|
432
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
|
+
}
|
|
433
436
|
}
|
|
434
437
|
}
|
|
435
|
-
else {
|
|
436
|
-
hookRunLog(`autofix: skip re-upload uuid=${inst.uuid} (no stored auth key)`);
|
|
437
|
-
}
|
|
438
438
|
const spec = remediationFixSpec(inst);
|
|
439
439
|
if (spec?.restart_required && spec.restart_command) {
|
|
440
440
|
if (!er.deferredSqlite) {
|