@atbash/sdk 0.3.11-dev.3 → 0.3.11-dev.4
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/index.cjs +38 -22
- package/dist/index.d.cts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +33 -17
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -105,6 +105,9 @@ function verifyJudgeResponseSignature(bodyBytes, signatureHex, pubKeyHex) {
|
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
// src/opentel/telemetry.ts
|
|
108
|
+
var import_node_fs = require("fs");
|
|
109
|
+
var import_node_os = require("os");
|
|
110
|
+
var import_node_path = require("path");
|
|
108
111
|
var import_sdk_metrics = require("@opentelemetry/sdk-metrics");
|
|
109
112
|
var import_exporter_metrics_otlp_http = require("@opentelemetry/exporter-metrics-otlp-http");
|
|
110
113
|
var import_resources = require("@opentelemetry/resources");
|
|
@@ -112,14 +115,27 @@ var meterProvider = null;
|
|
|
112
115
|
var callCounter = null;
|
|
113
116
|
var durationHistogram = null;
|
|
114
117
|
var defaultSource = "sdk";
|
|
118
|
+
function isTelemetryOptedOut() {
|
|
119
|
+
try {
|
|
120
|
+
const home = process.env.HOME || (0, import_node_os.homedir)() || "";
|
|
121
|
+
const filePath = (0, import_node_path.join)(home, ".config", "atbash", "telemetry.json");
|
|
122
|
+
const raw = (0, import_node_fs.readFileSync)(filePath, "utf-8").trim();
|
|
123
|
+
if (!raw) return false;
|
|
124
|
+
const config = JSON.parse(raw);
|
|
125
|
+
return config.enabled === false;
|
|
126
|
+
} catch {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
115
130
|
function autoInit() {
|
|
116
131
|
if (meterProvider) return;
|
|
117
|
-
if (
|
|
132
|
+
if (isTelemetryOptedOut()) return;
|
|
118
133
|
setupTelemetry({ enabled: true });
|
|
119
134
|
}
|
|
120
135
|
function setupTelemetry(config) {
|
|
121
136
|
if (!config.enabled) return;
|
|
122
137
|
if (meterProvider) return;
|
|
138
|
+
if (isTelemetryOptedOut()) return;
|
|
123
139
|
defaultSource = config.source ?? "sdk";
|
|
124
140
|
const ATBASH_HONEYCOMB_KEY = "YOUR_INGEST_KEY_HERE";
|
|
125
141
|
const apiKey = process.env.HONEYCOMB_API_KEY ?? ATBASH_HONEYCOMB_KEY;
|
|
@@ -698,22 +714,22 @@ function validateJudgeEndpoint(judge) {
|
|
|
698
714
|
}
|
|
699
715
|
|
|
700
716
|
// src/key-loader.ts
|
|
701
|
-
var
|
|
702
|
-
var
|
|
703
|
-
var
|
|
717
|
+
var import_node_fs2 = require("fs");
|
|
718
|
+
var import_node_os2 = require("os");
|
|
719
|
+
var import_node_path2 = require("path");
|
|
704
720
|
var DEFAULT_KEY_PATH_REL = ".config/atbash/guard-client-key";
|
|
705
721
|
function resolveKeyPath(input) {
|
|
706
722
|
if (input) return expandHome(input);
|
|
707
|
-
const home = process.env.HOME || (0,
|
|
708
|
-
return (0,
|
|
723
|
+
const home = process.env.HOME || (0, import_node_os2.homedir)() || "";
|
|
724
|
+
return (0, import_node_path2.join)(home, DEFAULT_KEY_PATH_REL);
|
|
709
725
|
}
|
|
710
726
|
function expandHome(p) {
|
|
711
727
|
if (!p.startsWith("~/")) return p;
|
|
712
|
-
const home = process.env.HOME || (0,
|
|
713
|
-
return (0,
|
|
728
|
+
const home = process.env.HOME || (0, import_node_os2.homedir)() || "";
|
|
729
|
+
return (0, import_node_path2.join)(home, p.slice(2));
|
|
714
730
|
}
|
|
715
731
|
function readKeyFile(keyPath) {
|
|
716
|
-
const content = String((0,
|
|
732
|
+
const content = String((0, import_node_fs2.readFileSync)(keyPath, "utf8") || "").trim();
|
|
717
733
|
let privKey = "";
|
|
718
734
|
let pubKey = "";
|
|
719
735
|
if (content.startsWith("{")) {
|
|
@@ -938,9 +954,9 @@ function truncate(text) {
|
|
|
938
954
|
}
|
|
939
955
|
|
|
940
956
|
// src/user-config.ts
|
|
941
|
-
var
|
|
942
|
-
var
|
|
943
|
-
var
|
|
957
|
+
var import_node_fs3 = require("fs");
|
|
958
|
+
var import_node_os3 = require("os");
|
|
959
|
+
var import_node_path3 = require("path");
|
|
944
960
|
var ENV_MAP = {
|
|
945
961
|
agentKey: "ATBASH_AGENT_KEY",
|
|
946
962
|
orgName: "ATBASH_ORG_NAME",
|
|
@@ -950,17 +966,17 @@ var ENV_MAP = {
|
|
|
950
966
|
providerModel: "ATBASH_PROVIDER_MODEL"
|
|
951
967
|
};
|
|
952
968
|
function getConfigDir() {
|
|
953
|
-
const home = process.env.HOME || (0,
|
|
954
|
-
return (0,
|
|
969
|
+
const home = process.env.HOME || (0, import_node_os3.homedir)() || "";
|
|
970
|
+
return (0, import_node_path3.join)(home, ".config", "atbash");
|
|
955
971
|
}
|
|
956
972
|
function getConfigPath() {
|
|
957
|
-
return (0,
|
|
973
|
+
return (0, import_node_path3.join)(getConfigDir(), "config.json");
|
|
958
974
|
}
|
|
959
975
|
function loadUserConfig() {
|
|
960
976
|
try {
|
|
961
977
|
const p = getConfigPath();
|
|
962
|
-
if (!(0,
|
|
963
|
-
const raw = (0,
|
|
978
|
+
if (!(0, import_node_fs3.existsSync)(p)) return {};
|
|
979
|
+
const raw = (0, import_node_fs3.readFileSync)(p, "utf-8").trim();
|
|
964
980
|
if (!raw) return {};
|
|
965
981
|
return JSON.parse(raw);
|
|
966
982
|
} catch (err) {
|
|
@@ -970,12 +986,12 @@ function loadUserConfig() {
|
|
|
970
986
|
}
|
|
971
987
|
function saveUserConfig(config) {
|
|
972
988
|
const dir = getConfigDir();
|
|
973
|
-
if (!(0,
|
|
974
|
-
(0,
|
|
989
|
+
if (!(0, import_node_fs3.existsSync)(dir)) {
|
|
990
|
+
(0, import_node_fs3.mkdirSync)(dir, { recursive: true, mode: 448 });
|
|
975
991
|
}
|
|
976
992
|
const filePath = getConfigPath();
|
|
977
|
-
(0,
|
|
978
|
-
(0,
|
|
993
|
+
(0, import_node_fs3.writeFileSync)(filePath, JSON.stringify(config, null, 2) + "\n", { mode: 384 });
|
|
994
|
+
(0, import_node_fs3.chmodSync)(filePath, 384);
|
|
979
995
|
}
|
|
980
996
|
function resolve(key, flagValue) {
|
|
981
997
|
if (flagValue) return flagValue;
|
|
@@ -1039,7 +1055,7 @@ var BEHAVIOR_PATTERNS = [
|
|
|
1039
1055
|
{
|
|
1040
1056
|
type: "privilege_escalation",
|
|
1041
1057
|
severity: "critical",
|
|
1042
|
-
re: /\b(?:admin|administrator|root|superuser|sudo|elevated)\b.*\b(?:
|
|
1058
|
+
re: /\b(?:admin|administrator|root|superuser|sudo|elevated)\b.*\b(?:privileges?|permissions?|access|roles?|clearance|authority)\b.*\b(?:granted|approved|confirmed|given|assigned)\b/i,
|
|
1043
1059
|
description: "claims elevated privileges were granted"
|
|
1044
1060
|
},
|
|
1045
1061
|
{
|
package/dist/index.d.cts
CHANGED
|
@@ -251,7 +251,11 @@ declare function verifyJudgeResponseSignature(bodyBytes: Uint8Array, signatureHe
|
|
|
251
251
|
* Atbash SDK Telemetry — OpenTelemetry metrics for usage tracking.
|
|
252
252
|
*
|
|
253
253
|
* Tracks: function call counts, latency, source (CLI/plugin/SDK),
|
|
254
|
-
* and agent identity.
|
|
254
|
+
* and agent identity. ON by default.
|
|
255
|
+
*
|
|
256
|
+
* Opt-out: create ~/.config/atbash/telemetry.json with { "enabled": false }
|
|
257
|
+
* The file must be mode 0600. If missing, corrupted, or unreadable → telemetry stays ON.
|
|
258
|
+
* Environment variables cannot disable telemetry (prevents agent bypass).
|
|
255
259
|
*/
|
|
256
260
|
type ClientSource = "cli" | "sdk" | "plugin:openclaw" | "plugin:langchain" | "plugin:langgraph" | "plugin:hermes" | "plugin:eliza" | "plugin:crewai" | "plugin:mcp" | "plugin:autogen" | "plugin:jeenai" | (string & {});
|
|
257
261
|
interface TelemetryConfig {
|
package/dist/index.d.ts
CHANGED
|
@@ -251,7 +251,11 @@ declare function verifyJudgeResponseSignature(bodyBytes: Uint8Array, signatureHe
|
|
|
251
251
|
* Atbash SDK Telemetry — OpenTelemetry metrics for usage tracking.
|
|
252
252
|
*
|
|
253
253
|
* Tracks: function call counts, latency, source (CLI/plugin/SDK),
|
|
254
|
-
* and agent identity.
|
|
254
|
+
* and agent identity. ON by default.
|
|
255
|
+
*
|
|
256
|
+
* Opt-out: create ~/.config/atbash/telemetry.json with { "enabled": false }
|
|
257
|
+
* The file must be mode 0600. If missing, corrupted, or unreadable → telemetry stays ON.
|
|
258
|
+
* Environment variables cannot disable telemetry (prevents agent bypass).
|
|
255
259
|
*/
|
|
256
260
|
type ClientSource = "cli" | "sdk" | "plugin:openclaw" | "plugin:langchain" | "plugin:langgraph" | "plugin:hermes" | "plugin:eliza" | "plugin:crewai" | "plugin:mcp" | "plugin:autogen" | "plugin:jeenai" | (string & {});
|
|
257
261
|
interface TelemetryConfig {
|
package/dist/index.js
CHANGED
|
@@ -29,6 +29,9 @@ function verifyJudgeResponseSignature(bodyBytes, signatureHex, pubKeyHex) {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
// src/opentel/telemetry.ts
|
|
32
|
+
import { readFileSync } from "fs";
|
|
33
|
+
import { homedir } from "os";
|
|
34
|
+
import { join } from "path";
|
|
32
35
|
import { MeterProvider, PeriodicExportingMetricReader } from "@opentelemetry/sdk-metrics";
|
|
33
36
|
import { OTLPMetricExporter } from "@opentelemetry/exporter-metrics-otlp-http";
|
|
34
37
|
import { resourceFromAttributes } from "@opentelemetry/resources";
|
|
@@ -36,14 +39,27 @@ var meterProvider = null;
|
|
|
36
39
|
var callCounter = null;
|
|
37
40
|
var durationHistogram = null;
|
|
38
41
|
var defaultSource = "sdk";
|
|
42
|
+
function isTelemetryOptedOut() {
|
|
43
|
+
try {
|
|
44
|
+
const home = process.env.HOME || homedir() || "";
|
|
45
|
+
const filePath = join(home, ".config", "atbash", "telemetry.json");
|
|
46
|
+
const raw = readFileSync(filePath, "utf-8").trim();
|
|
47
|
+
if (!raw) return false;
|
|
48
|
+
const config = JSON.parse(raw);
|
|
49
|
+
return config.enabled === false;
|
|
50
|
+
} catch {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
39
54
|
function autoInit() {
|
|
40
55
|
if (meterProvider) return;
|
|
41
|
-
if (
|
|
56
|
+
if (isTelemetryOptedOut()) return;
|
|
42
57
|
setupTelemetry({ enabled: true });
|
|
43
58
|
}
|
|
44
59
|
function setupTelemetry(config) {
|
|
45
60
|
if (!config.enabled) return;
|
|
46
61
|
if (meterProvider) return;
|
|
62
|
+
if (isTelemetryOptedOut()) return;
|
|
47
63
|
defaultSource = config.source ?? "sdk";
|
|
48
64
|
const ATBASH_HONEYCOMB_KEY = "YOUR_INGEST_KEY_HERE";
|
|
49
65
|
const apiKey = process.env.HONEYCOMB_API_KEY ?? ATBASH_HONEYCOMB_KEY;
|
|
@@ -622,22 +638,22 @@ function validateJudgeEndpoint(judge) {
|
|
|
622
638
|
}
|
|
623
639
|
|
|
624
640
|
// src/key-loader.ts
|
|
625
|
-
import { readFileSync } from "fs";
|
|
626
|
-
import { homedir } from "os";
|
|
627
|
-
import { join } from "path";
|
|
641
|
+
import { readFileSync as readFileSync2 } from "fs";
|
|
642
|
+
import { homedir as homedir2 } from "os";
|
|
643
|
+
import { join as join2 } from "path";
|
|
628
644
|
var DEFAULT_KEY_PATH_REL = ".config/atbash/guard-client-key";
|
|
629
645
|
function resolveKeyPath(input) {
|
|
630
646
|
if (input) return expandHome(input);
|
|
631
|
-
const home = process.env.HOME ||
|
|
632
|
-
return
|
|
647
|
+
const home = process.env.HOME || homedir2() || "";
|
|
648
|
+
return join2(home, DEFAULT_KEY_PATH_REL);
|
|
633
649
|
}
|
|
634
650
|
function expandHome(p) {
|
|
635
651
|
if (!p.startsWith("~/")) return p;
|
|
636
|
-
const home = process.env.HOME ||
|
|
637
|
-
return
|
|
652
|
+
const home = process.env.HOME || homedir2() || "";
|
|
653
|
+
return join2(home, p.slice(2));
|
|
638
654
|
}
|
|
639
655
|
function readKeyFile(keyPath) {
|
|
640
|
-
const content = String(
|
|
656
|
+
const content = String(readFileSync2(keyPath, "utf8") || "").trim();
|
|
641
657
|
let privKey = "";
|
|
642
658
|
let pubKey = "";
|
|
643
659
|
if (content.startsWith("{")) {
|
|
@@ -862,9 +878,9 @@ function truncate(text) {
|
|
|
862
878
|
}
|
|
863
879
|
|
|
864
880
|
// src/user-config.ts
|
|
865
|
-
import { readFileSync as
|
|
866
|
-
import { homedir as
|
|
867
|
-
import { join as
|
|
881
|
+
import { readFileSync as readFileSync3, writeFileSync, mkdirSync, chmodSync, existsSync } from "fs";
|
|
882
|
+
import { homedir as homedir3 } from "os";
|
|
883
|
+
import { join as join3 } from "path";
|
|
868
884
|
var ENV_MAP = {
|
|
869
885
|
agentKey: "ATBASH_AGENT_KEY",
|
|
870
886
|
orgName: "ATBASH_ORG_NAME",
|
|
@@ -874,17 +890,17 @@ var ENV_MAP = {
|
|
|
874
890
|
providerModel: "ATBASH_PROVIDER_MODEL"
|
|
875
891
|
};
|
|
876
892
|
function getConfigDir() {
|
|
877
|
-
const home = process.env.HOME ||
|
|
878
|
-
return
|
|
893
|
+
const home = process.env.HOME || homedir3() || "";
|
|
894
|
+
return join3(home, ".config", "atbash");
|
|
879
895
|
}
|
|
880
896
|
function getConfigPath() {
|
|
881
|
-
return
|
|
897
|
+
return join3(getConfigDir(), "config.json");
|
|
882
898
|
}
|
|
883
899
|
function loadUserConfig() {
|
|
884
900
|
try {
|
|
885
901
|
const p = getConfigPath();
|
|
886
902
|
if (!existsSync(p)) return {};
|
|
887
|
-
const raw =
|
|
903
|
+
const raw = readFileSync3(p, "utf-8").trim();
|
|
888
904
|
if (!raw) return {};
|
|
889
905
|
return JSON.parse(raw);
|
|
890
906
|
} catch (err) {
|
|
@@ -963,7 +979,7 @@ var BEHAVIOR_PATTERNS = [
|
|
|
963
979
|
{
|
|
964
980
|
type: "privilege_escalation",
|
|
965
981
|
severity: "critical",
|
|
966
|
-
re: /\b(?:admin|administrator|root|superuser|sudo|elevated)\b.*\b(?:
|
|
982
|
+
re: /\b(?:admin|administrator|root|superuser|sudo|elevated)\b.*\b(?:privileges?|permissions?|access|roles?|clearance|authority)\b.*\b(?:granted|approved|confirmed|given|assigned)\b/i,
|
|
967
983
|
description: "claims elevated privileges were granted"
|
|
968
984
|
},
|
|
969
985
|
{
|
package/package.json
CHANGED