@atbash/sdk 0.16.4-dev.0 → 0.16.5-dev.0

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.js CHANGED
@@ -3362,6 +3362,7 @@ var callCounter = null;
3362
3362
  var durationHistogram = null;
3363
3363
  var defaultSource = "sdk";
3364
3364
  var sourceExplicitlySet = false;
3365
+ var requestedExportIntervalMs;
3365
3366
  function isTelemetryOptedOut() {
3366
3367
  const disabled = process.env.ATBASH_TELEMETRY_DISABLED?.trim().toLowerCase();
3367
3368
  if (disabled && ["1", "true", "yes", "on"].includes(disabled)) {
@@ -3390,18 +3391,36 @@ function setupTelemetry(config2) {
3390
3391
  defaultSource = config2.source;
3391
3392
  sourceExplicitlySet = true;
3392
3393
  }
3394
+ if (config2.exportIntervalMs !== void 0 && requestedExportIntervalMs === void 0) {
3395
+ requestedExportIntervalMs = config2.exportIntervalMs;
3396
+ }
3393
3397
  if (meterProvider) return;
3394
3398
  if (!config2.endpoint || !config2.getAuthHeaders) return;
3395
- if (/^https?:\/\/(localhost|127\.0\.0\.1|0\.0\.0\.0)(:|\/|$)/i.test(config2.endpoint)) return;
3399
+ if (/^https?:\/\/(localhost|127\.0\.0\.1|0\.0\.0\.0)(:|\/|$)/i.test(
3400
+ config2.endpoint
3401
+ ))
3402
+ return;
3396
3403
  const proxyUrl = `${config2.endpoint.replace(/\/+$/, "")}/api/telemetry`;
3397
3404
  const getAuthHeaders = config2.getAuthHeaders;
3398
3405
  const exporter = new import_exporter_metrics_otlp_http.OTLPMetricExporter({
3399
3406
  url: proxyUrl,
3400
- headers: async () => getAuthHeaders()
3407
+ headers: async () => getAuthHeaders(),
3408
+ // DELTA, not the OTel default of CUMULATIVE.
3409
+ //
3410
+ // A cumulative counter reports a running total, and the backend recovers
3411
+ // the increment by differencing consecutive points of a series. That needs
3412
+ // at least two points. Most Atbash callers are short-lived — a CLI run
3413
+ // exports once and exits — so their series has exactly one point, nothing
3414
+ // to difference against, and the usage board reads them as zero: the calls
3415
+ // arrive, carry the right `source`, and still count for nothing.
3416
+ //
3417
+ // A delta counter reports the increment itself, so a single export is a
3418
+ // whole truthful datapoint and SUM over any window is the real call count.
3419
+ temporalityPreference: import_exporter_metrics_otlp_http.AggregationTemporalityPreference.DELTA
3401
3420
  });
3402
3421
  const reader = new import_sdk_metrics.PeriodicExportingMetricReader({
3403
3422
  exporter,
3404
- exportIntervalMillis: config2.exportIntervalMs ?? 6e4
3423
+ exportIntervalMillis: requestedExportIntervalMs ?? 6e4
3405
3424
  });
3406
3425
  meterProvider = new import_sdk_metrics.MeterProvider({
3407
3426
  resource: (0, import_resources.resourceFromAttributes)({
@@ -3447,6 +3466,7 @@ async function shutdownTelemetry() {
3447
3466
  durationHistogram = null;
3448
3467
  defaultSource = "sdk";
3449
3468
  sourceExplicitlySet = false;
3469
+ requestedExportIntervalMs = void 0;
3450
3470
  }
3451
3471
 
3452
3472
  // src-ts/userConfig.ts
package/dist/index.mjs CHANGED
@@ -3258,7 +3258,10 @@ function canonicalAllow(data) {
3258
3258
  import { readFileSync as readFileSync2 } from "fs";
3259
3259
  import { homedir as homedir2 } from "os";
3260
3260
  import { join as join2 } from "path";
3261
- import { OTLPMetricExporter } from "@opentelemetry/exporter-metrics-otlp-http";
3261
+ import {
3262
+ AggregationTemporalityPreference,
3263
+ OTLPMetricExporter
3264
+ } from "@opentelemetry/exporter-metrics-otlp-http";
3262
3265
  import { resourceFromAttributes } from "@opentelemetry/resources";
3263
3266
  import {
3264
3267
  MeterProvider,
@@ -3269,6 +3272,7 @@ var callCounter = null;
3269
3272
  var durationHistogram = null;
3270
3273
  var defaultSource = "sdk";
3271
3274
  var sourceExplicitlySet = false;
3275
+ var requestedExportIntervalMs;
3272
3276
  function isTelemetryOptedOut() {
3273
3277
  const disabled = process.env.ATBASH_TELEMETRY_DISABLED?.trim().toLowerCase();
3274
3278
  if (disabled && ["1", "true", "yes", "on"].includes(disabled)) {
@@ -3297,18 +3301,36 @@ function setupTelemetry(config2) {
3297
3301
  defaultSource = config2.source;
3298
3302
  sourceExplicitlySet = true;
3299
3303
  }
3304
+ if (config2.exportIntervalMs !== void 0 && requestedExportIntervalMs === void 0) {
3305
+ requestedExportIntervalMs = config2.exportIntervalMs;
3306
+ }
3300
3307
  if (meterProvider) return;
3301
3308
  if (!config2.endpoint || !config2.getAuthHeaders) return;
3302
- if (/^https?:\/\/(localhost|127\.0\.0\.1|0\.0\.0\.0)(:|\/|$)/i.test(config2.endpoint)) return;
3309
+ if (/^https?:\/\/(localhost|127\.0\.0\.1|0\.0\.0\.0)(:|\/|$)/i.test(
3310
+ config2.endpoint
3311
+ ))
3312
+ return;
3303
3313
  const proxyUrl = `${config2.endpoint.replace(/\/+$/, "")}/api/telemetry`;
3304
3314
  const getAuthHeaders = config2.getAuthHeaders;
3305
3315
  const exporter = new OTLPMetricExporter({
3306
3316
  url: proxyUrl,
3307
- headers: async () => getAuthHeaders()
3317
+ headers: async () => getAuthHeaders(),
3318
+ // DELTA, not the OTel default of CUMULATIVE.
3319
+ //
3320
+ // A cumulative counter reports a running total, and the backend recovers
3321
+ // the increment by differencing consecutive points of a series. That needs
3322
+ // at least two points. Most Atbash callers are short-lived — a CLI run
3323
+ // exports once and exits — so their series has exactly one point, nothing
3324
+ // to difference against, and the usage board reads them as zero: the calls
3325
+ // arrive, carry the right `source`, and still count for nothing.
3326
+ //
3327
+ // A delta counter reports the increment itself, so a single export is a
3328
+ // whole truthful datapoint and SUM over any window is the real call count.
3329
+ temporalityPreference: AggregationTemporalityPreference.DELTA
3308
3330
  });
3309
3331
  const reader = new PeriodicExportingMetricReader({
3310
3332
  exporter,
3311
- exportIntervalMillis: config2.exportIntervalMs ?? 6e4
3333
+ exportIntervalMillis: requestedExportIntervalMs ?? 6e4
3312
3334
  });
3313
3335
  meterProvider = new MeterProvider({
3314
3336
  resource: resourceFromAttributes({
@@ -3354,6 +3376,7 @@ async function shutdownTelemetry() {
3354
3376
  durationHistogram = null;
3355
3377
  defaultSource = "sdk";
3356
3378
  sourceExplicitlySet = false;
3379
+ requestedExportIntervalMs = void 0;
3357
3380
  }
3358
3381
 
3359
3382
  // src-ts/userConfig.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atbash/sdk",
3
- "version": "0.16.4-dev.0",
3
+ "version": "0.16.5-dev.0",
4
4
  "description": "TypeScript SDK for Atbash — the safety layer that evaluates AI agent actions against operator-defined policies before execution.",
5
5
  "keywords": [
6
6
  "atbash",
@@ -89,10 +89,10 @@
89
89
  "typescript-eslint": "^8.62.1"
90
90
  },
91
91
  "optionalDependencies": {
92
- "@atbash/sdk-linux-x64-gnu": "0.16.4-dev.0",
93
- "@atbash/sdk-linux-arm64-gnu": "0.16.4-dev.0",
94
- "@atbash/sdk-linux-x64-musl": "0.16.4-dev.0",
95
- "@atbash/sdk-darwin-arm64": "0.16.4-dev.0",
96
- "@atbash/sdk-win32-x64-msvc": "0.16.4-dev.0"
92
+ "@atbash/sdk-linux-x64-gnu": "0.16.5-dev.0",
93
+ "@atbash/sdk-linux-arm64-gnu": "0.16.5-dev.0",
94
+ "@atbash/sdk-linux-x64-musl": "0.16.5-dev.0",
95
+ "@atbash/sdk-darwin-arm64": "0.16.5-dev.0",
96
+ "@atbash/sdk-win32-x64-msvc": "0.16.5-dev.0"
97
97
  }
98
98
  }