modelstat 0.1.1 → 0.1.3
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 +81 -16
- package/dist/cli.mjs.map +1 -1
- package/package.json +3 -3
package/dist/cli.mjs
CHANGED
|
@@ -4624,16 +4624,22 @@ function redact(text, repoRootAbs) {
|
|
|
4624
4624
|
});
|
|
4625
4625
|
}
|
|
4626
4626
|
out = out.replace(TOKEN_CANDIDATE, (match) => {
|
|
4627
|
-
if (/^[a-
|
|
4628
|
-
|
|
4629
|
-
|
|
4627
|
+
if (/^[a-fA-F0-9]{32,}$/.test(match)) {
|
|
4628
|
+
counts.secrets_found += 1;
|
|
4629
|
+
return "[REDACTED:hash]";
|
|
4630
|
+
}
|
|
4631
|
+
if (/^[A-Z0-9_]+$/.test(match)) return match;
|
|
4632
|
+
if (/=$|\+/.test(match) && entropy(match) >= 3.5) {
|
|
4633
|
+
counts.secrets_found += 1;
|
|
4634
|
+
return "[REDACTED:base64]";
|
|
4635
|
+
}
|
|
4630
4636
|
const hasDigit = /\d/.test(match);
|
|
4631
4637
|
const hasUpper = /[A-Z]/.test(match);
|
|
4632
4638
|
const hasLower = /[a-z]/.test(match);
|
|
4633
|
-
if (!(
|
|
4639
|
+
if (!(hasDigit && hasUpper && hasLower)) return match;
|
|
4634
4640
|
if (entropy(match) < 3.6) return match;
|
|
4635
4641
|
counts.secrets_found += 1;
|
|
4636
|
-
return
|
|
4642
|
+
return "[REDACTED:hi-entropy]";
|
|
4637
4643
|
});
|
|
4638
4644
|
out = out.replace(EMAIL_PATTERN, () => {
|
|
4639
4645
|
counts.emails_redacted += 1;
|
|
@@ -5107,8 +5113,10 @@ var init_schemas = __esm({
|
|
|
5107
5113
|
object: external_exports.string().max(60).nullable().default(null),
|
|
5108
5114
|
/** Governed safe flags (`destructive`, `remote`, …). (tier 0) */
|
|
5109
5115
|
qualifiers: external_exports.array(external_exports.string().max(40)).max(8).default([]),
|
|
5110
|
-
/** Value-masked argument skeleton (every value → `§`).
|
|
5111
|
-
|
|
5116
|
+
/** Value-masked argument skeleton (every value → `§`). Carried in full up
|
|
5117
|
+
* to a malicious-size guard (mirrors backend `MAX_TOOL_ACTION_PARAM_SHAPE_CHARS`);
|
|
5118
|
+
* the companion clamps rather than truncating semantically. (tier 1) */
|
|
5119
|
+
param_shape: external_exports.string().max(16384).nullable().default(null),
|
|
5112
5120
|
/** Relevant non-sensitive keywords (e.g. ["rollout","restart","prod"]),
|
|
5113
5121
|
* OpenAI-redacted on-device. (tier 0) */
|
|
5114
5122
|
keywords: external_exports.array(external_exports.string().max(40)).max(12).default([]),
|
|
@@ -5118,7 +5126,7 @@ var init_schemas = __esm({
|
|
|
5118
5126
|
/** The compliance-redacted command text — PII/secrets stripped on-device
|
|
5119
5127
|
* (SOC2/GDPR), org-internal infra intact; the server derives semantics from
|
|
5120
5128
|
* it. Un-redacted raw never ships. (tier 0, post-redaction) */
|
|
5121
|
-
command_redacted: external_exports.string().max(
|
|
5129
|
+
command_redacted: external_exports.string().max(16384).nullable().default(null),
|
|
5122
5130
|
/** Per-script content abstracts for any script/bash FILES the command runs
|
|
5123
5131
|
* — summarized on-device by the local model, then redacted. Ordered by
|
|
5124
5132
|
* appearance; `token` is the script's token exactly as it appears in
|
|
@@ -5377,6 +5385,10 @@ var init_scripts = __esm({
|
|
|
5377
5385
|
});
|
|
5378
5386
|
|
|
5379
5387
|
// ../../packages/parsers/src/tool-action/index.ts
|
|
5388
|
+
function clampChars(s, max) {
|
|
5389
|
+
const cps = [...s];
|
|
5390
|
+
return cps.length > max ? cps.slice(0, max).join("") : s;
|
|
5391
|
+
}
|
|
5380
5392
|
function extractToolAction(call) {
|
|
5381
5393
|
const isMcp = call.server.startsWith("mcp:");
|
|
5382
5394
|
const command = isMcp ? null : shellCommandOf(call.input);
|
|
@@ -5387,8 +5399,8 @@ function extractToolAction(call) {
|
|
|
5387
5399
|
if (command != null) {
|
|
5388
5400
|
const [head = "", ...rest] = command.trim().split(/\s+/);
|
|
5389
5401
|
executable = basename(head) || null;
|
|
5390
|
-
param_shape = paramShape(rest.join(" ")) || null;
|
|
5391
|
-
command_redacted = redact(command, call.cwd ?? void 0).text
|
|
5402
|
+
param_shape = clampChars(paramShape(rest.join(" ")), MAX_FIELD_CHARS) || null;
|
|
5403
|
+
command_redacted = clampChars(redact(command, call.cwd ?? void 0).text, MAX_FIELD_CHARS) || null;
|
|
5392
5404
|
}
|
|
5393
5405
|
return {
|
|
5394
5406
|
surface,
|
|
@@ -5426,13 +5438,13 @@ function shellCommandOf(input) {
|
|
|
5426
5438
|
function basename(token) {
|
|
5427
5439
|
return token.split("/").pop() ?? token;
|
|
5428
5440
|
}
|
|
5429
|
-
var
|
|
5441
|
+
var MAX_FIELD_CHARS;
|
|
5430
5442
|
var init_tool_action = __esm({
|
|
5431
5443
|
"../../packages/parsers/src/tool-action/index.ts"() {
|
|
5432
5444
|
"use strict";
|
|
5433
5445
|
init_src();
|
|
5434
5446
|
init_scripts();
|
|
5435
|
-
|
|
5447
|
+
MAX_FIELD_CHARS = 16384;
|
|
5436
5448
|
}
|
|
5437
5449
|
});
|
|
5438
5450
|
|
|
@@ -8538,6 +8550,33 @@ async function probeIdentities(os2) {
|
|
|
8538
8550
|
} catch {
|
|
8539
8551
|
}
|
|
8540
8552
|
}
|
|
8553
|
+
const claudeConfigs = [`${homedir()}/.claude.json`];
|
|
8554
|
+
if (process.env.CLAUDE_CONFIG_DIR) {
|
|
8555
|
+
claudeConfigs.unshift(`${process.env.CLAUDE_CONFIG_DIR}/.claude.json`);
|
|
8556
|
+
}
|
|
8557
|
+
for (const candidate of claudeConfigs) {
|
|
8558
|
+
if (!existsSync3(candidate)) continue;
|
|
8559
|
+
try {
|
|
8560
|
+
const data = await fs4.promises.readFile(candidate, "utf8");
|
|
8561
|
+
const obj = JSON.parse(data);
|
|
8562
|
+
const acct = obj.oauthAccount;
|
|
8563
|
+
const stableId = acct?.accountUuid ?? acct?.organizationUuid;
|
|
8564
|
+
if (acct && stableId) {
|
|
8565
|
+
ids.push({
|
|
8566
|
+
provider: "anthropic",
|
|
8567
|
+
provider_account_id: stableId,
|
|
8568
|
+
provider_account_label: acct.emailAddress ?? acct.organizationName ?? acct.displayName ?? "Claude account",
|
|
8569
|
+
account_email: acct.emailAddress ?? null,
|
|
8570
|
+
account_org: acct.organizationName ?? acct.billingType ?? null,
|
|
8571
|
+
display_name: acct.displayName ?? null,
|
|
8572
|
+
owner_scope: "unassigned",
|
|
8573
|
+
detection_source: "claude_json_oauth"
|
|
8574
|
+
});
|
|
8575
|
+
break;
|
|
8576
|
+
}
|
|
8577
|
+
} catch {
|
|
8578
|
+
}
|
|
8579
|
+
}
|
|
8541
8580
|
for (const candidate of [
|
|
8542
8581
|
`${homedir()}/.codex/auth.json`,
|
|
8543
8582
|
`${homedir()}/.config/codex/auth.json`
|
|
@@ -46436,6 +46475,17 @@ function basenameFromUrl(url) {
|
|
|
46436
46475
|
const parts = clean.split("/");
|
|
46437
46476
|
return parts[parts.length - 1] || "model.gguf";
|
|
46438
46477
|
}
|
|
46478
|
+
async function disposeLlama() {
|
|
46479
|
+
const inst = llamaInstance;
|
|
46480
|
+
llamaInstance = null;
|
|
46481
|
+
loaded = null;
|
|
46482
|
+
loadPromise = null;
|
|
46483
|
+
if (!inst) return;
|
|
46484
|
+
try {
|
|
46485
|
+
await inst.dispose();
|
|
46486
|
+
} catch {
|
|
46487
|
+
}
|
|
46488
|
+
}
|
|
46439
46489
|
async function ensureLlamaModel(cfg = defaultLlamaConfig()) {
|
|
46440
46490
|
if (existsSync7(cfg.modelPath)) return cfg.modelPath;
|
|
46441
46491
|
await mkdir(dirname5(cfg.modelPath), { recursive: true });
|
|
@@ -46506,6 +46556,7 @@ async function loadOnce(cfg) {
|
|
|
46506
46556
|
const llamaMod = await import("node-llama-cpp");
|
|
46507
46557
|
const modelPath = await ensureLlamaModel(cfg);
|
|
46508
46558
|
const llama = await llamaMod.getLlama();
|
|
46559
|
+
llamaInstance = llama;
|
|
46509
46560
|
const model = await llama.loadModel({ modelPath });
|
|
46510
46561
|
const summariserContext = await model.createContext({
|
|
46511
46562
|
contextSize: cfg.contextSize
|
|
@@ -46689,7 +46740,7 @@ function llamaExtractLinks(cfg = defaultLlamaConfig()) {
|
|
|
46689
46740
|
}
|
|
46690
46741
|
};
|
|
46691
46742
|
}
|
|
46692
|
-
var DEFAULT_LLAMA_MODEL_URL, LLAMA_MAX_TOKENS, loaded, loadPromise, inflight;
|
|
46743
|
+
var DEFAULT_LLAMA_MODEL_URL, LLAMA_MAX_TOKENS, loaded, loadPromise, inflight, llamaInstance;
|
|
46693
46744
|
var init_llama = __esm({
|
|
46694
46745
|
"../../packages/companion-core/src/node/llama.ts"() {
|
|
46695
46746
|
"use strict";
|
|
@@ -46703,6 +46754,7 @@ var init_llama = __esm({
|
|
|
46703
46754
|
loaded = null;
|
|
46704
46755
|
loadPromise = null;
|
|
46705
46756
|
inflight = Promise.resolve();
|
|
46757
|
+
llamaInstance = null;
|
|
46706
46758
|
}
|
|
46707
46759
|
});
|
|
46708
46760
|
|
|
@@ -46911,6 +46963,7 @@ __export(node_exports, {
|
|
|
46911
46963
|
createTransformersJsEmbedder: () => createTransformersJsEmbedder,
|
|
46912
46964
|
defaultLlamaConfig: () => defaultLlamaConfig,
|
|
46913
46965
|
defaultOllamaConfig: () => defaultOllamaConfig,
|
|
46966
|
+
disposeLlama: () => disposeLlama,
|
|
46914
46967
|
ensureLlamaModel: () => ensureLlamaModel,
|
|
46915
46968
|
llamaCognize: () => llamaCognize,
|
|
46916
46969
|
llamaEntitle: () => llamaEntitle,
|
|
@@ -47426,7 +47479,7 @@ var init_scan = __esm({
|
|
|
47426
47479
|
init_api();
|
|
47427
47480
|
init_config2();
|
|
47428
47481
|
init_pipeline2();
|
|
47429
|
-
AGENT_VERSION = true ? "agent-0.1.
|
|
47482
|
+
AGENT_VERSION = true ? "agent-0.1.3" : "agent-dev";
|
|
47430
47483
|
BATCH_MAX_EVENTS = INGEST_BATCH_MAX_EVENTS;
|
|
47431
47484
|
BATCH_MAX_TOOL_CALLS = 2e4;
|
|
47432
47485
|
BATCH_BUFFER_HARD_CAP = BATCH_MAX_EVENTS * 2;
|
|
@@ -49911,6 +49964,11 @@ async function runDaemon(opts = {}) {
|
|
|
49911
49964
|
setPhase("offline", "Shutting down");
|
|
49912
49965
|
await sendHeartbeat();
|
|
49913
49966
|
await watcher.close();
|
|
49967
|
+
try {
|
|
49968
|
+
const { disposeLlama: disposeLlama2 } = await Promise.resolve().then(() => (init_node2(), node_exports));
|
|
49969
|
+
await disposeLlama2();
|
|
49970
|
+
} catch {
|
|
49971
|
+
}
|
|
49914
49972
|
process.exit(0);
|
|
49915
49973
|
};
|
|
49916
49974
|
process.on("SIGINT", shutdown);
|
|
@@ -49931,7 +49989,7 @@ var init_daemon = __esm({
|
|
|
49931
49989
|
init_machine_key();
|
|
49932
49990
|
init_scan();
|
|
49933
49991
|
init_single_flight();
|
|
49934
|
-
AGENT_VERSION2 = true ? "agent-0.1.
|
|
49992
|
+
AGENT_VERSION2 = true ? "agent-0.1.3" : "agent-dev";
|
|
49935
49993
|
HEARTBEAT_INTERVAL_MS = 1e4;
|
|
49936
49994
|
SCAN_INTERVAL_MS = 5 * 60 * 1e3;
|
|
49937
49995
|
DISCOVERY_INTERVAL_MS = 6e4;
|
|
@@ -50063,6 +50121,7 @@ import { createInterface as createInterface3 } from "readline";
|
|
|
50063
50121
|
// src/service.ts
|
|
50064
50122
|
import { spawn, spawnSync as spawnSync2 } from "child_process";
|
|
50065
50123
|
import {
|
|
50124
|
+
chmodSync as chmodSync3,
|
|
50066
50125
|
copyFileSync,
|
|
50067
50126
|
existsSync as existsSync9,
|
|
50068
50127
|
mkdirSync as mkdirSync3,
|
|
@@ -50377,6 +50436,7 @@ function installTrayApp(sourceAppPath) {
|
|
|
50377
50436
|
if (r.status !== 0) {
|
|
50378
50437
|
throw new Error(`cp ModelstatTray.app failed: ${r.stderr?.trim() || `exit ${r.status}`}`);
|
|
50379
50438
|
}
|
|
50439
|
+
chmodSync3(join7(dest, "Contents", "MacOS", "modelstat-tray"), 493);
|
|
50380
50440
|
return { installedAt: dest };
|
|
50381
50441
|
}
|
|
50382
50442
|
async function bundledTrayAppPath(progress) {
|
|
@@ -50531,7 +50591,7 @@ function tryOpenBrowser(url) {
|
|
|
50531
50591
|
return false;
|
|
50532
50592
|
}
|
|
50533
50593
|
}
|
|
50534
|
-
var AGENT_VERSION3 = true ? "agent-0.1.
|
|
50594
|
+
var AGENT_VERSION3 = true ? "agent-0.1.3" : "agent-dev";
|
|
50535
50595
|
function osFamily() {
|
|
50536
50596
|
const p = platform5();
|
|
50537
50597
|
if (p === "darwin") return "macos";
|
|
@@ -50905,6 +50965,11 @@ async function cmdScan() {
|
|
|
50905
50965
|
console.log(
|
|
50906
50966
|
`Done: ${r.filesScanned} files scanned, ${r.filesUnchanged} unchanged, ${r.batchesUploaded} batches, ${r.segmentsUploaded} segments, ${r.eventsUploaded} events uploaded`
|
|
50907
50967
|
);
|
|
50968
|
+
try {
|
|
50969
|
+
const { disposeLlama: disposeLlama2 } = await Promise.resolve().then(() => (init_node2(), node_exports));
|
|
50970
|
+
await disposeLlama2();
|
|
50971
|
+
} catch {
|
|
50972
|
+
}
|
|
50908
50973
|
}
|
|
50909
50974
|
async function cmdRescan() {
|
|
50910
50975
|
const { PROCESSING_VERSION: PROCESSING_VERSION2 } = await Promise.resolve().then(() => (init_processing_version(), processing_version_exports));
|