log-llm-config-staging 1.4.3 → 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,11 +1,9 @@
|
|
|
1
1
|
import { execFileSync } from 'node:child_process';
|
|
2
|
-
import { createRequire } from 'node:module';
|
|
3
2
|
import { homedir } from 'node:os';
|
|
4
3
|
import { join } from 'node:path';
|
|
5
|
-
import { fileURLToPath } from 'node:url';
|
|
6
4
|
export const SKILLS_CLI_FILE_TYPE = 'skills_cli_installed';
|
|
7
5
|
export const SKILLS_CLI_INSTALLED_PATH = join(homedir(), '.agents', '.skills-cli-installed.json');
|
|
8
|
-
/** Override
|
|
6
|
+
/** Override the skills package spec, e.g. `skills@1.5.10`. Default uses whatever is on the machine. */
|
|
9
7
|
export const SKILLS_CLI_NPX_PACKAGE_ENV = 'SKILLS_CLI_NPX_PACKAGE';
|
|
10
8
|
const LIST_TIMEOUT_MS = 120_000;
|
|
11
9
|
function listExecEnv() {
|
|
@@ -14,46 +12,17 @@ function listExecEnv() {
|
|
|
14
12
|
DISABLE_TELEMETRY: process.env.DISABLE_TELEMETRY ?? '1',
|
|
15
13
|
};
|
|
16
14
|
}
|
|
17
|
-
function
|
|
15
|
+
function npxPackageSpec() {
|
|
18
16
|
const fromEnv = (process.env[SKILLS_CLI_NPX_PACKAGE_ENV] || '').trim();
|
|
19
17
|
return fromEnv || 'skills';
|
|
20
18
|
}
|
|
21
|
-
function
|
|
22
|
-
|
|
23
|
-
const require = createRequire(fileURLToPath(import.meta.url));
|
|
24
|
-
const bin = require.resolve('skills/bin/cli.mjs');
|
|
25
|
-
const pkg = require('skills/package.json');
|
|
26
|
-
const version = (pkg.version || '').trim() || 'unknown';
|
|
27
|
-
return { mode: 'bundled', bin, version };
|
|
28
|
-
}
|
|
29
|
-
catch {
|
|
30
|
-
return { mode: 'npx', packageSpec: npxPackageSpecForFallback() };
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
function execSkillsList(args, cwd, runner) {
|
|
34
|
-
if (runner.mode === 'bundled') {
|
|
35
|
-
return execFileSync(process.execPath, [runner.bin, 'list', ...args, '--json'], {
|
|
36
|
-
encoding: 'utf8',
|
|
37
|
-
cwd,
|
|
38
|
-
timeout: LIST_TIMEOUT_MS,
|
|
39
|
-
env: listExecEnv(),
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
return execFileSync('npx', ['--yes', runner.packageSpec, 'list', ...args, '--json'], {
|
|
19
|
+
export function runSkillsListJson(args, cwd) {
|
|
20
|
+
const out = execFileSync('npx', [npxPackageSpec(), 'list', ...args, '--json'], {
|
|
43
21
|
encoding: 'utf8',
|
|
44
22
|
cwd,
|
|
45
23
|
timeout: LIST_TIMEOUT_MS,
|
|
46
24
|
env: listExecEnv(),
|
|
47
25
|
});
|
|
48
|
-
}
|
|
49
|
-
function runnerVersionLabel(runner) {
|
|
50
|
-
if (runner.mode === 'bundled')
|
|
51
|
-
return runner.version;
|
|
52
|
-
return `npx:${runner.packageSpec}`;
|
|
53
|
-
}
|
|
54
|
-
export function runSkillsListJson(args, cwd) {
|
|
55
|
-
const runner = resolveSkillsListRunner();
|
|
56
|
-
const out = execSkillsList(args, cwd, runner);
|
|
57
26
|
const trimmed = out.trim();
|
|
58
27
|
if (!trimmed)
|
|
59
28
|
return [];
|
|
@@ -96,13 +65,8 @@ export function collectSkillsCliInstalled(projectRoot, log) {
|
|
|
96
65
|
log?.(message);
|
|
97
66
|
};
|
|
98
67
|
try {
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
logLine(`skills_cli: bundled skills@${runner.version} — list -g --json && list --json (projectRoot=${projectRoot})`);
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
logLine(`skills_cli: npx fallback (${runner.packageSpec}) — no bundled skills dep; uses machine npx cache (projectRoot=${projectRoot})`);
|
|
105
|
-
}
|
|
68
|
+
const packageSpec = npxPackageSpec();
|
|
69
|
+
logLine(`skills_cli: npx ${packageSpec} — list -g --json && list --json (projectRoot=${projectRoot})`);
|
|
106
70
|
const globalRows = runSkillsListJson(['-g'], projectRoot);
|
|
107
71
|
const projectRows = runSkillsListJson([], projectRoot);
|
|
108
72
|
const global = normalizeListRows(globalRows, 'global');
|
|
@@ -111,7 +75,7 @@ export function collectSkillsCliInstalled(projectRoot, log) {
|
|
|
111
75
|
logLine(formatSkillsListScopeForHookLog('project', project));
|
|
112
76
|
const payload = {
|
|
113
77
|
version: 1,
|
|
114
|
-
skills_cli_version:
|
|
78
|
+
skills_cli_version: packageSpec,
|
|
115
79
|
generated_at: new Date().toISOString(),
|
|
116
80
|
global,
|
|
117
81
|
project,
|
|
@@ -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
|
-
|
|
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
|
|
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.
|
|
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": {
|
|
@@ -58,7 +58,6 @@
|
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"axios": "^1.15.2",
|
|
60
60
|
"canonicalize": "^2.1.0",
|
|
61
|
-
"optimus-tofu-staging": "^0.1.17"
|
|
62
|
-
"skills": "1.5.10"
|
|
61
|
+
"optimus-tofu-staging": "^0.1.17"
|
|
63
62
|
}
|
|
64
63
|
}
|