modelstat 0.3.0 → 0.3.2
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.
- package/dist/cli.mjs +225 -12
- package/dist/cli.mjs.map +1 -1
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -4620,9 +4620,13 @@ var init_redact_floor = __esm({
|
|
|
4620
4620
|
replacement: "<REDACTED:modelstat_device_secret>"
|
|
4621
4621
|
},
|
|
4622
4622
|
// Generic env-style KEY=VALUE where KEY names a secret. Keeps the var name.
|
|
4623
|
+
// The keyword may be the WHOLE name (`SECRET=`, `TOKEN=`) or part of it
|
|
4624
|
+
// (`AWS_SECRET_ACCESS_KEY=`), so the prefix is `[A-Z0-9_]*` (zero-or-more) —
|
|
4625
|
+
// a mandatory leading `[A-Z]` here used to eat the first letter and miss every
|
|
4626
|
+
// bare-keyword name, leaking `SECRET="…"` / `TOKEN="…"` straight to the wire.
|
|
4623
4627
|
{
|
|
4624
4628
|
name: "env_secret",
|
|
4625
|
-
pattern: /\b([A-
|
|
4629
|
+
pattern: /\b([A-Z0-9_]*(?:TOKEN|KEY|SECRET|PASSWORD|PASSWD|PASSPHRASE|CREDENTIAL|API)[A-Z0-9_]*)\s*[:=]\s*['"]?([^\s'"]{12,})['"]?/g,
|
|
4626
4630
|
replacement: "$1=<REDACTED:env_secret>"
|
|
4627
4631
|
},
|
|
4628
4632
|
{
|
|
@@ -5200,7 +5204,7 @@ var init_schemas = __esm({
|
|
|
5200
5204
|
scripts: external_exports.array(external_exports.object({ token: external_exports.string().max(200), summary: external_exports.string().max(200) })).max(8).default([]),
|
|
5201
5205
|
/** Extractor confidence in [0, 1]. */
|
|
5202
5206
|
confidence: external_exports.number().min(0).max(1).default(0),
|
|
5203
|
-
/** Provenance of the extraction, e.g. `shell.
|
|
5207
|
+
/** Provenance of the extraction, e.g. `shell.v3`. */
|
|
5204
5208
|
extractor: external_exports.string().max(40)
|
|
5205
5209
|
}).strict();
|
|
5206
5210
|
ToolCallWire = external_exports.object({
|
|
@@ -5390,6 +5394,214 @@ var init_src = __esm({
|
|
|
5390
5394
|
}
|
|
5391
5395
|
});
|
|
5392
5396
|
|
|
5397
|
+
// ../../packages/parsers/src/tool-action/executable.ts
|
|
5398
|
+
function splitStatements(command) {
|
|
5399
|
+
const out = [];
|
|
5400
|
+
let cur = "";
|
|
5401
|
+
let single = false;
|
|
5402
|
+
let double = false;
|
|
5403
|
+
for (let i = 0; i < command.length; i++) {
|
|
5404
|
+
const c = command[i];
|
|
5405
|
+
if (single) {
|
|
5406
|
+
cur += c;
|
|
5407
|
+
if (c === "'") single = false;
|
|
5408
|
+
continue;
|
|
5409
|
+
}
|
|
5410
|
+
if (double) {
|
|
5411
|
+
if (c === "\\" && i + 1 < command.length) {
|
|
5412
|
+
cur += c + command[i + 1];
|
|
5413
|
+
i++;
|
|
5414
|
+
continue;
|
|
5415
|
+
}
|
|
5416
|
+
cur += c;
|
|
5417
|
+
if (c === '"') double = false;
|
|
5418
|
+
continue;
|
|
5419
|
+
}
|
|
5420
|
+
if (c === "'") {
|
|
5421
|
+
single = true;
|
|
5422
|
+
cur += c;
|
|
5423
|
+
continue;
|
|
5424
|
+
}
|
|
5425
|
+
if (c === '"') {
|
|
5426
|
+
double = true;
|
|
5427
|
+
cur += c;
|
|
5428
|
+
continue;
|
|
5429
|
+
}
|
|
5430
|
+
if (c === "\\" && i + 1 < command.length) {
|
|
5431
|
+
cur += c + command[i + 1];
|
|
5432
|
+
i++;
|
|
5433
|
+
continue;
|
|
5434
|
+
}
|
|
5435
|
+
if (c === "#" && (cur === "" || /\s$/.test(cur))) {
|
|
5436
|
+
out.push(cur);
|
|
5437
|
+
cur = "";
|
|
5438
|
+
while (i + 1 < command.length && command[i + 1] !== "\n") i++;
|
|
5439
|
+
continue;
|
|
5440
|
+
}
|
|
5441
|
+
if (c === "\n" || c === ";") {
|
|
5442
|
+
out.push(cur);
|
|
5443
|
+
cur = "";
|
|
5444
|
+
continue;
|
|
5445
|
+
}
|
|
5446
|
+
if (c === "&" || c === "|") {
|
|
5447
|
+
out.push(cur);
|
|
5448
|
+
cur = "";
|
|
5449
|
+
if (command[i + 1] === c) i++;
|
|
5450
|
+
continue;
|
|
5451
|
+
}
|
|
5452
|
+
cur += c;
|
|
5453
|
+
}
|
|
5454
|
+
out.push(cur);
|
|
5455
|
+
return out;
|
|
5456
|
+
}
|
|
5457
|
+
function basename(token) {
|
|
5458
|
+
const parts = token.split("/");
|
|
5459
|
+
return parts[parts.length - 1] ?? token;
|
|
5460
|
+
}
|
|
5461
|
+
function stripOpener(token) {
|
|
5462
|
+
let t = token;
|
|
5463
|
+
if (t.startsWith("$(")) t = t.slice(2);
|
|
5464
|
+
else if (t.startsWith("(")) t = t.slice(1);
|
|
5465
|
+
if (t.startsWith("`")) t = t.slice(1);
|
|
5466
|
+
return t;
|
|
5467
|
+
}
|
|
5468
|
+
function substitutionProgram(token) {
|
|
5469
|
+
const rhs = token.slice(token.indexOf("=") + 1);
|
|
5470
|
+
if (rhs.startsWith("$((")) return null;
|
|
5471
|
+
if (rhs.startsWith("$(") || rhs.startsWith("`")) {
|
|
5472
|
+
const inner = stripOpener(rhs);
|
|
5473
|
+
return inner || null;
|
|
5474
|
+
}
|
|
5475
|
+
return null;
|
|
5476
|
+
}
|
|
5477
|
+
function looksLikeProgram(cand) {
|
|
5478
|
+
if (!PROGRAM.test(cand)) return false;
|
|
5479
|
+
if (/^\d+$/.test(cand)) return false;
|
|
5480
|
+
if ((cand.match(/\./g)?.length ?? 0) >= 2) return false;
|
|
5481
|
+
const lower = cand.toLowerCase();
|
|
5482
|
+
return !DATA_EXTENSIONS.some((ext) => lower.endsWith(ext));
|
|
5483
|
+
}
|
|
5484
|
+
function scanStatement(stmt) {
|
|
5485
|
+
for (const tok of stmt.split(/\s+/).filter(Boolean)) {
|
|
5486
|
+
let t = tok;
|
|
5487
|
+
if (BRACKETS.has(t) || FUNCTION_DEF.test(t) || WRAPPERS.has(t)) continue;
|
|
5488
|
+
if (ASSIGNMENT.test(t)) {
|
|
5489
|
+
const sub = substitutionProgram(t);
|
|
5490
|
+
if (sub) t = sub;
|
|
5491
|
+
else continue;
|
|
5492
|
+
}
|
|
5493
|
+
const cand = basename(stripOpener(t).replace(/[)"'`;,]+$/, "")).toLowerCase();
|
|
5494
|
+
if (!cand || cand.startsWith("-")) break;
|
|
5495
|
+
if (NOISE_BUILTINS.has(cand)) return { builtin: cand };
|
|
5496
|
+
if (looksLikeProgram(cand)) return { program: cand };
|
|
5497
|
+
break;
|
|
5498
|
+
}
|
|
5499
|
+
return {};
|
|
5500
|
+
}
|
|
5501
|
+
function extractExecutable(command) {
|
|
5502
|
+
let fallback = null;
|
|
5503
|
+
for (const raw of splitStatements(command)) {
|
|
5504
|
+
const stmt = raw.trim();
|
|
5505
|
+
if (!stmt || stmt.startsWith("#")) continue;
|
|
5506
|
+
const { program, builtin } = scanStatement(stmt);
|
|
5507
|
+
if (program) {
|
|
5508
|
+
return program.length > MAX_EXECUTABLE_CHARS ? OTHER_BUCKET : program;
|
|
5509
|
+
}
|
|
5510
|
+
if (builtin && !fallback) fallback = builtin;
|
|
5511
|
+
}
|
|
5512
|
+
return fallback ?? OTHER_BUCKET;
|
|
5513
|
+
}
|
|
5514
|
+
var OTHER_BUCKET, MAX_EXECUTABLE_CHARS, WRAPPERS, BRACKETS, NOISE_BUILTINS, DATA_EXTENSIONS, ASSIGNMENT, FUNCTION_DEF, PROGRAM;
|
|
5515
|
+
var init_executable = __esm({
|
|
5516
|
+
"../../packages/parsers/src/tool-action/executable.ts"() {
|
|
5517
|
+
"use strict";
|
|
5518
|
+
OTHER_BUCKET = "(other)";
|
|
5519
|
+
MAX_EXECUTABLE_CHARS = 80;
|
|
5520
|
+
WRAPPERS = /* @__PURE__ */ new Set([
|
|
5521
|
+
"sudo",
|
|
5522
|
+
"doas",
|
|
5523
|
+
"env",
|
|
5524
|
+
"command",
|
|
5525
|
+
"exec",
|
|
5526
|
+
"builtin",
|
|
5527
|
+
"nohup",
|
|
5528
|
+
"setsid",
|
|
5529
|
+
"time",
|
|
5530
|
+
"nice",
|
|
5531
|
+
"ionice",
|
|
5532
|
+
"chrt",
|
|
5533
|
+
"stdbuf",
|
|
5534
|
+
"xargs",
|
|
5535
|
+
// control-flow openers that immediately precede a command
|
|
5536
|
+
"then",
|
|
5537
|
+
"do",
|
|
5538
|
+
"else"
|
|
5539
|
+
]);
|
|
5540
|
+
BRACKETS = /* @__PURE__ */ new Set(["{", "}", "(", ")"]);
|
|
5541
|
+
NOISE_BUILTINS = /* @__PURE__ */ new Set([
|
|
5542
|
+
"cd",
|
|
5543
|
+
"pushd",
|
|
5544
|
+
"popd",
|
|
5545
|
+
"echo",
|
|
5546
|
+
"printf",
|
|
5547
|
+
"export",
|
|
5548
|
+
"unset",
|
|
5549
|
+
"set",
|
|
5550
|
+
"readonly",
|
|
5551
|
+
"typeset",
|
|
5552
|
+
"declare",
|
|
5553
|
+
"local",
|
|
5554
|
+
"alias",
|
|
5555
|
+
"source",
|
|
5556
|
+
".",
|
|
5557
|
+
"eval",
|
|
5558
|
+
":",
|
|
5559
|
+
"true",
|
|
5560
|
+
"false",
|
|
5561
|
+
"read",
|
|
5562
|
+
"wait",
|
|
5563
|
+
"trap",
|
|
5564
|
+
"umask",
|
|
5565
|
+
"shift",
|
|
5566
|
+
"return",
|
|
5567
|
+
"getopts",
|
|
5568
|
+
"hash",
|
|
5569
|
+
"let",
|
|
5570
|
+
"test",
|
|
5571
|
+
"[",
|
|
5572
|
+
"[[",
|
|
5573
|
+
// loop / conditional keywords
|
|
5574
|
+
"for",
|
|
5575
|
+
"while",
|
|
5576
|
+
"until",
|
|
5577
|
+
"if",
|
|
5578
|
+
"elif",
|
|
5579
|
+
"fi",
|
|
5580
|
+
"case",
|
|
5581
|
+
"esac",
|
|
5582
|
+
"select",
|
|
5583
|
+
"function",
|
|
5584
|
+
"done"
|
|
5585
|
+
]);
|
|
5586
|
+
DATA_EXTENSIONS = [
|
|
5587
|
+
".output",
|
|
5588
|
+
".txt",
|
|
5589
|
+
".log",
|
|
5590
|
+
".json",
|
|
5591
|
+
".jsonl",
|
|
5592
|
+
".md",
|
|
5593
|
+
".csv",
|
|
5594
|
+
".tmp",
|
|
5595
|
+
".out",
|
|
5596
|
+
".git",
|
|
5597
|
+
".lock"
|
|
5598
|
+
];
|
|
5599
|
+
ASSIGNMENT = /^[A-Za-z_][A-Za-z0-9_]*=/;
|
|
5600
|
+
FUNCTION_DEF = /^[A-Za-z_][A-Za-z0-9_]*\(\)?$/;
|
|
5601
|
+
PROGRAM = /^[A-Za-z0-9][A-Za-z0-9._+-]*$/;
|
|
5602
|
+
}
|
|
5603
|
+
});
|
|
5604
|
+
|
|
5393
5605
|
// ../../packages/parsers/src/tool-action/scripts.ts
|
|
5394
5606
|
function detectScriptRefs(command) {
|
|
5395
5607
|
const refs = [];
|
|
@@ -5462,9 +5674,9 @@ function extractToolAction(call) {
|
|
|
5462
5674
|
let param_shape = null;
|
|
5463
5675
|
let command_redacted = null;
|
|
5464
5676
|
if (command != null) {
|
|
5465
|
-
|
|
5466
|
-
|
|
5467
|
-
param_shape = clampChars(paramShape(
|
|
5677
|
+
executable = extractExecutable(command);
|
|
5678
|
+
const args = command.trim().split(/\s+/).slice(1).join(" ");
|
|
5679
|
+
param_shape = clampChars(paramShape(args), MAX_FIELD_CHARS) || null;
|
|
5468
5680
|
command_redacted = clampChars(redact(command, call.cwd ?? void 0).text, MAX_FIELD_CHARS) || null;
|
|
5469
5681
|
}
|
|
5470
5682
|
return {
|
|
@@ -5479,7 +5691,9 @@ function extractToolAction(call) {
|
|
|
5479
5691
|
command_redacted,
|
|
5480
5692
|
scripts: [],
|
|
5481
5693
|
confidence: 0,
|
|
5482
|
-
|
|
5694
|
+
// Per-surface provenance. shell bumped to v3 (normalized executable, see
|
|
5695
|
+
// `extractExecutable`); builtin/mcp extraction is unchanged → still v1.
|
|
5696
|
+
extractor: `${surface}.${surface === "shell" ? "v3" : "v1"}`
|
|
5483
5697
|
};
|
|
5484
5698
|
}
|
|
5485
5699
|
function extractLocalToolContext(call) {
|
|
@@ -5500,14 +5714,13 @@ function shellCommandOf(input) {
|
|
|
5500
5714
|
}
|
|
5501
5715
|
return null;
|
|
5502
5716
|
}
|
|
5503
|
-
function basename(token) {
|
|
5504
|
-
return token.split("/").pop() ?? token;
|
|
5505
|
-
}
|
|
5506
5717
|
var MAX_FIELD_CHARS;
|
|
5507
5718
|
var init_tool_action = __esm({
|
|
5508
5719
|
"../../packages/parsers/src/tool-action/index.ts"() {
|
|
5509
5720
|
"use strict";
|
|
5510
5721
|
init_src();
|
|
5722
|
+
init_executable();
|
|
5723
|
+
init_executable();
|
|
5511
5724
|
init_scripts();
|
|
5512
5725
|
MAX_FIELD_CHARS = 16384;
|
|
5513
5726
|
}
|
|
@@ -47573,7 +47786,7 @@ var init_scan = __esm({
|
|
|
47573
47786
|
init_api();
|
|
47574
47787
|
init_config2();
|
|
47575
47788
|
init_pipeline2();
|
|
47576
|
-
DAEMON_VERSION = true ? "daemon-0.3.
|
|
47789
|
+
DAEMON_VERSION = true ? "daemon-0.3.2" : "daemon-dev";
|
|
47577
47790
|
BATCH_MAX_EVENTS = INGEST_BATCH_MAX_EVENTS;
|
|
47578
47791
|
BATCH_MAX_TOOL_CALLS = 2e4;
|
|
47579
47792
|
BATCH_BUFFER_HARD_CAP = BATCH_MAX_EVENTS * 2;
|
|
@@ -50083,7 +50296,7 @@ var init_daemon = __esm({
|
|
|
50083
50296
|
init_machine_key();
|
|
50084
50297
|
init_scan();
|
|
50085
50298
|
init_single_flight();
|
|
50086
|
-
DAEMON_VERSION2 = true ? "daemon-0.3.
|
|
50299
|
+
DAEMON_VERSION2 = true ? "daemon-0.3.2" : "daemon-dev";
|
|
50087
50300
|
HEARTBEAT_INTERVAL_MS = 1e4;
|
|
50088
50301
|
SCAN_INTERVAL_MS = 5 * 60 * 1e3;
|
|
50089
50302
|
DISCOVERY_INTERVAL_MS = 6e4;
|
|
@@ -50685,7 +50898,7 @@ function tryOpenBrowser(url) {
|
|
|
50685
50898
|
return false;
|
|
50686
50899
|
}
|
|
50687
50900
|
}
|
|
50688
|
-
var DAEMON_VERSION3 = true ? "daemon-0.3.
|
|
50901
|
+
var DAEMON_VERSION3 = true ? "daemon-0.3.2" : "daemon-dev";
|
|
50689
50902
|
function osFamily() {
|
|
50690
50903
|
const p = platform5();
|
|
50691
50904
|
if (p === "darwin") return "macos";
|