@atbash/sdk 0.3.19 → 0.3.20

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 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 (process.env.ATBASH_TELEMETRY === "false") return;
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 = "AmHeTVLSAeOELUkol0EVSK";
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 import_node_fs = require("fs");
702
- var import_node_os = require("os");
703
- var import_node_path = require("path");
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, import_node_os.homedir)() || "";
708
- return (0, import_node_path.join)(home, DEFAULT_KEY_PATH_REL);
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, import_node_os.homedir)() || "";
713
- return (0, import_node_path.join)(home, p.slice(2));
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, import_node_fs.readFileSync)(keyPath, "utf8") || "").trim();
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 import_node_fs2 = require("fs");
942
- var import_node_os2 = require("os");
943
- var import_node_path2 = require("path");
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, import_node_os2.homedir)() || "";
954
- return (0, import_node_path2.join)(home, ".config", "atbash");
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, import_node_path2.join)(getConfigDir(), "config.json");
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, import_node_fs2.existsSync)(p)) return {};
963
- const raw = (0, import_node_fs2.readFileSync)(p, "utf-8").trim();
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, import_node_fs2.existsSync)(dir)) {
974
- (0, import_node_fs2.mkdirSync)(dir, { recursive: true, mode: 448 });
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, import_node_fs2.writeFileSync)(filePath, JSON.stringify(config, null, 2) + "\n", { mode: 384 });
978
- (0, import_node_fs2.chmodSync)(filePath, 384);
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;
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. Opt-in no data sent unless enabled.
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. Opt-in no data sent unless enabled.
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 (process.env.ATBASH_TELEMETRY === "false") return;
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 = "AmHeTVLSAeOELUkol0EVSK";
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 || homedir() || "";
632
- return join(home, DEFAULT_KEY_PATH_REL);
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 || homedir() || "";
637
- return join(home, p.slice(2));
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(readFileSync(keyPath, "utf8") || "").trim();
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 readFileSync2, writeFileSync, mkdirSync, chmodSync, existsSync } from "fs";
866
- import { homedir as homedir2 } from "os";
867
- import { join as join2 } from "path";
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 || homedir2() || "";
878
- return join2(home, ".config", "atbash");
893
+ const home = process.env.HOME || homedir3() || "";
894
+ return join3(home, ".config", "atbash");
879
895
  }
880
896
  function getConfigPath() {
881
- return join2(getConfigDir(), "config.json");
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 = readFileSync2(p, "utf-8").trim();
903
+ const raw = readFileSync3(p, "utf-8").trim();
888
904
  if (!raw) return {};
889
905
  return JSON.parse(raw);
890
906
  } catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atbash/sdk",
3
- "version": "0.3.19",
3
+ "version": "0.3.20",
4
4
  "description": "Atbash SDK — control boundary before the last irreversible step in an agent workflow",
5
5
  "homepage": "https://atbash.ai",
6
6
  "author": "Atbash",