@atbash/sdk 0.10.10-dev.0 → 0.10.11-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/README.md +12 -2
- package/dist/browser.d.mts +33 -7
- package/dist/browser.mjs +44 -16
- package/dist/browser.mjs.map +1 -1
- package/dist/index.d.mts +33 -7
- package/dist/index.d.ts +33 -7
- package/dist/index.js +54 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +54 -19
- package/dist/index.mjs.map +1 -1
- package/index.d.ts +0 -2
- package/index.js +0 -1
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -3216,6 +3216,10 @@ var callCounter = null;
|
|
|
3216
3216
|
var durationHistogram = null;
|
|
3217
3217
|
var defaultSource = "sdk";
|
|
3218
3218
|
function isTelemetryOptedOut() {
|
|
3219
|
+
const disabled = process.env.ATBASH_TELEMETRY_DISABLED?.trim().toLowerCase();
|
|
3220
|
+
if (disabled && ["1", "true", "yes", "on"].includes(disabled)) {
|
|
3221
|
+
return true;
|
|
3222
|
+
}
|
|
3219
3223
|
try {
|
|
3220
3224
|
const home2 = process.env.HOME || homedir2() || "";
|
|
3221
3225
|
const filePath = join2(home2, ".config", "atbash", "telemetry.json");
|
|
@@ -3236,14 +3240,14 @@ function setupTelemetry(config2) {
|
|
|
3236
3240
|
if (!config2.enabled) return;
|
|
3237
3241
|
if (meterProvider) return;
|
|
3238
3242
|
if (isTelemetryOptedOut()) return;
|
|
3243
|
+
if (!config2.endpoint || !config2.getAuthHeaders) return;
|
|
3244
|
+
if (/^https?:\/\/(localhost|127\.0\.0\.1|0\.0\.0\.0)(:|\/|$)/i.test(config2.endpoint)) return;
|
|
3239
3245
|
defaultSource = config2.source ?? "sdk";
|
|
3240
|
-
const
|
|
3241
|
-
|
|
3246
|
+
const proxyUrl = `${config2.endpoint.replace(/\/+$/, "")}/api/telemetry`;
|
|
3247
|
+
const getAuthHeaders = config2.getAuthHeaders;
|
|
3242
3248
|
const exporter = new OTLPMetricExporter({
|
|
3243
|
-
url:
|
|
3244
|
-
headers:
|
|
3245
|
-
"x-honeycomb-team": apiKey
|
|
3246
|
-
}
|
|
3249
|
+
url: proxyUrl,
|
|
3250
|
+
headers: async () => getAuthHeaders()
|
|
3247
3251
|
});
|
|
3248
3252
|
const reader = new PeriodicExportingMetricReader({
|
|
3249
3253
|
exporter,
|
|
@@ -3418,6 +3422,16 @@ var Atbash = class _Atbash {
|
|
|
3418
3422
|
verifying: this.verifyPubKey ? "with response-signature pubkey configured" : "without signature verification"
|
|
3419
3423
|
});
|
|
3420
3424
|
}
|
|
3425
|
+
try {
|
|
3426
|
+
setupTelemetry({
|
|
3427
|
+
enabled: true,
|
|
3428
|
+
source: "sdk",
|
|
3429
|
+
endpoint: this.endpoint,
|
|
3430
|
+
getAuthHeaders: () => this.authHeaders()
|
|
3431
|
+
});
|
|
3432
|
+
} catch (err) {
|
|
3433
|
+
this.logger.warn?.("[atbash] telemetry setup failed \u2014 continuing without metrics", { error: String(err) });
|
|
3434
|
+
}
|
|
3421
3435
|
}
|
|
3422
3436
|
/**
|
|
3423
3437
|
* Say which environment this build talks to, once per process.
|
|
@@ -3931,19 +3945,25 @@ var Atbash = class _Atbash {
|
|
|
3931
3945
|
});
|
|
3932
3946
|
}
|
|
3933
3947
|
/* ── risk-engine batched (action-dispatched POST) ──────────────────────── */
|
|
3934
|
-
getAgentDetail(agentPubkey) {
|
|
3935
|
-
return this.track(
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3948
|
+
async getAgentDetail(agentPubkey, options = {}) {
|
|
3949
|
+
return this.track("getAgentDetail", agentPubkey, async () => {
|
|
3950
|
+
const network = await this.resolveAgentLookupNetwork(options);
|
|
3951
|
+
return this.riskEnginePost(
|
|
3952
|
+
{ action: "agent-detail-batch", agent: agentPubkey },
|
|
3953
|
+
network
|
|
3954
|
+
);
|
|
3955
|
+
});
|
|
3940
3956
|
}
|
|
3941
|
-
async getAgentPolicy(agentPubkey) {
|
|
3957
|
+
async getAgentPolicy(agentPubkey, options = {}) {
|
|
3942
3958
|
return this.track("getAgentPolicy", agentPubkey, async () => {
|
|
3943
|
-
const
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3959
|
+
const network = await this.resolveAgentLookupNetwork(options);
|
|
3960
|
+
const raw2 = await this.riskEnginePost(
|
|
3961
|
+
{
|
|
3962
|
+
action: "agent-policy-batch",
|
|
3963
|
+
agent: agentPubkey
|
|
3964
|
+
},
|
|
3965
|
+
network
|
|
3966
|
+
);
|
|
3947
3967
|
return {
|
|
3948
3968
|
policy: String(raw2.policy ?? ""),
|
|
3949
3969
|
isJailed: Boolean(raw2.is_jailed),
|
|
@@ -4100,6 +4120,20 @@ var Atbash = class _Atbash {
|
|
|
4100
4120
|
if (chainOpts?.network === "public") return PUBLIC_CHAIN.blockchainRid;
|
|
4101
4121
|
return this.blockchainRid;
|
|
4102
4122
|
}
|
|
4123
|
+
/**
|
|
4124
|
+
* Resolve the dashboard chain used by agent metadata/policy reads.
|
|
4125
|
+
* Explicit per-call network overrides win; otherwise use the supplied org
|
|
4126
|
+
* or the client's configured default org. A custom BRID is intentionally
|
|
4127
|
+
* left untouched because it cannot be represented by the dashboard's
|
|
4128
|
+
* public/private query selector.
|
|
4129
|
+
*/
|
|
4130
|
+
async resolveAgentLookupNetwork(options) {
|
|
4131
|
+
if (options.chainOpts?.network) return options.chainOpts.network;
|
|
4132
|
+
if (options.chainOpts?.blockchainRid) return void 0;
|
|
4133
|
+
const orgName = options.orgName ?? this.orgName;
|
|
4134
|
+
if (!orgName) return void 0;
|
|
4135
|
+
return (await this.resolveChainForOrg(orgName)).network;
|
|
4136
|
+
}
|
|
4103
4137
|
/**
|
|
4104
4138
|
* Get-or-create a Bearer token for dashboard reads. The token is a
|
|
4105
4139
|
* signed `log_tool_call` op (locally signed, never submitted) — the
|
|
@@ -4142,10 +4176,11 @@ var Atbash = class _Atbash {
|
|
|
4142
4176
|
if (resp.status !== 200) throw await this.httpError(resp);
|
|
4143
4177
|
return this.json(resp);
|
|
4144
4178
|
}
|
|
4145
|
-
async riskEnginePost(body) {
|
|
4179
|
+
async riskEnginePost(body, network) {
|
|
4146
4180
|
let resp;
|
|
4147
4181
|
try {
|
|
4148
|
-
|
|
4182
|
+
const path7 = network ? `/api/risk-engine?network=${encodeURIComponent(network)}` : "/api/risk-engine";
|
|
4183
|
+
resp = await this.http.post(path7, body, this.authHeaders());
|
|
4149
4184
|
} catch (err) {
|
|
4150
4185
|
throw this.transportError(err);
|
|
4151
4186
|
}
|