@atbash/sdk 0.18.0-dev.0 → 0.19.0-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 +75 -12
- package/dist/browser.d.mts +145 -1
- package/dist/browser.mjs +108 -25
- package/dist/index.d.mts +145 -1
- package/dist/index.d.ts +145 -1
- package/dist/index.js +256 -40
- package/dist/index.mjs +253 -40
- package/package.json +9 -6
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Logger } from '@opentelemetry/api-logs';
|
|
2
|
+
|
|
1
3
|
type JudgeEndpointConfig = {
|
|
2
4
|
policy?: "default";
|
|
3
5
|
endpoint?: string;
|
|
@@ -1233,6 +1235,19 @@ interface GuardMemoryWriteResult {
|
|
|
1233
1235
|
/** Present when handled. True only after the chain transaction confirms. */
|
|
1234
1236
|
committed?: boolean;
|
|
1235
1237
|
}
|
|
1238
|
+
/**
|
|
1239
|
+
* Guard a memory write, and record what was decided.
|
|
1240
|
+
*
|
|
1241
|
+
* Wraps the decision rather than threading telemetry through its eight exits,
|
|
1242
|
+
* so a later return added inside cannot quietly stop being counted.
|
|
1243
|
+
*
|
|
1244
|
+
* Only a call this guard actually handled is recorded. A tool call that was
|
|
1245
|
+
* never a memory write is not a memory operation, and counting it would put
|
|
1246
|
+
* every unrelated edit into the number a memory migration reads.
|
|
1247
|
+
*
|
|
1248
|
+
* @param input - The tool call and the agent to judge it for.
|
|
1249
|
+
* @returns What the guard decided; unchanged by the recording.
|
|
1250
|
+
*/
|
|
1236
1251
|
declare function guardMemoryWrite(input: GuardMemoryWriteInput): Promise<GuardMemoryWriteResult>;
|
|
1237
1252
|
|
|
1238
1253
|
/**
|
|
@@ -1641,6 +1656,20 @@ interface TelemetryConfig {
|
|
|
1641
1656
|
* `{ Authorization: "Bearer <hex>" }`). Required to actually export.
|
|
1642
1657
|
*/
|
|
1643
1658
|
getAuthHeaders?: () => Record<string, string>;
|
|
1659
|
+
/**
|
|
1660
|
+
* Hashes the agent key before it is emitted on a wide event.
|
|
1661
|
+
*
|
|
1662
|
+
* Defaults to an unsalted SHA-256, which is de-identification rather than
|
|
1663
|
+
* anonymisation: agent pubkeys are public on chain and can be enumerated, so
|
|
1664
|
+
* the mapping is recoverable by anyone holding that list. Supply a salted
|
|
1665
|
+
* hasher to make it uncorrelatable, at the cost of joining across
|
|
1666
|
+
* deployments.
|
|
1667
|
+
*
|
|
1668
|
+
* Injected rather than imported so the telemetry modules need nothing from
|
|
1669
|
+
* the native addon. Left unset, the agent field is dropped from events
|
|
1670
|
+
* rather than falling back to the raw key.
|
|
1671
|
+
*/
|
|
1672
|
+
hashAgentKey?: (pubkeyHex: string) => string;
|
|
1644
1673
|
}
|
|
1645
1674
|
declare function setupTelemetry(config: TelemetryConfig): void;
|
|
1646
1675
|
/**
|
|
@@ -1663,6 +1692,121 @@ declare function flushTelemetry(): Promise<void>;
|
|
|
1663
1692
|
*/
|
|
1664
1693
|
declare function shutdownTelemetry(): Promise<void>;
|
|
1665
1694
|
|
|
1695
|
+
/**
|
|
1696
|
+
* Wide events: one row per SDK operation, alongside the counters.
|
|
1697
|
+
*
|
|
1698
|
+
* The counters in `telemetry.ts` are aggregated inside this process before
|
|
1699
|
+
* export, so Honeycomb never receives a per-operation row. That is fine for
|
|
1700
|
+
* "is it up" and useless for everything else: a question nobody attached an
|
|
1701
|
+
* attribute for in advance cannot be answered later, because the data to
|
|
1702
|
+
* answer it never existed. "Which org sees the most failures", "what preceded
|
|
1703
|
+
* a fail-closed", "is the new release slower" are all that shape.
|
|
1704
|
+
*
|
|
1705
|
+
* So each operation also emits one event carrying its whole context. The
|
|
1706
|
+
* counters stay — they are the right tool for health boards and alerts, and
|
|
1707
|
+
* they are not sampled.
|
|
1708
|
+
*
|
|
1709
|
+
* TWO RULES SHAPE THIS MODULE.
|
|
1710
|
+
*
|
|
1711
|
+
* The payload is METADATA ONLY, and the allowlist below is the whole of it:
|
|
1712
|
+
* function name, outcome, latency, error class, error status and path, SDK
|
|
1713
|
+
* version, chain, and a hash of the agent key. Action text, tool arguments, policy text, organisation
|
|
1714
|
+
* names and keys never appear — not as a field that is emptied, but as a field
|
|
1715
|
+
* that does not exist, so there is nothing to forget to strip.
|
|
1716
|
+
*
|
|
1717
|
+
* The agent key is hashed, never sent raw, and the hasher is INJECTED rather
|
|
1718
|
+
* than imported: this module needs nothing from the native addon. With no
|
|
1719
|
+
* hasher supplied the field is DROPPED rather than falling back to the raw
|
|
1720
|
+
* key, so the guarantee does not depend on wiring somebody could forget.
|
|
1721
|
+
*
|
|
1722
|
+
* NOTE on what hashing does and does not buy. Agent pubkeys are public on
|
|
1723
|
+
* chain and can be enumerated, so an UNSALTED hash is reversible by anyone who
|
|
1724
|
+
* can read the chain: it is de-identification, not anonymisation. A salted
|
|
1725
|
+
* hasher makes it uncorrelatable and costs cross-deployment joins. Which one
|
|
1726
|
+
* is wanted is the caller's decision; this module only guarantees the raw key
|
|
1727
|
+
* never leaves.
|
|
1728
|
+
*
|
|
1729
|
+
* And the richer payload has its own switch. Counters carry a function name
|
|
1730
|
+
* and a source. These events carry agent and org identity off a customer's
|
|
1731
|
+
* machine, which is a different proposition for a security product, so
|
|
1732
|
+
* `ATBASH_TELEMETRY_EVENTS_DISABLED=1` turns them off while leaving the health
|
|
1733
|
+
* counters on. Both remain subject to the existing global opt-out.
|
|
1734
|
+
*/
|
|
1735
|
+
|
|
1736
|
+
/** Attributes an event may carry. Anything not listed here cannot be emitted. */
|
|
1737
|
+
interface OperationEvent {
|
|
1738
|
+
/** SDK function, matching the counter's `function.name` so the two join. */
|
|
1739
|
+
functionName: string;
|
|
1740
|
+
durationMs: number;
|
|
1741
|
+
status: "success" | "error";
|
|
1742
|
+
/**
|
|
1743
|
+
* Hex pubkey of the agent the call was made as. Hashed before it is emitted,
|
|
1744
|
+
* and omitted entirely when no hasher is configured.
|
|
1745
|
+
*/
|
|
1746
|
+
agentPubkey?: string;
|
|
1747
|
+
/**
|
|
1748
|
+
* Blockchain RID of the chain this call concerned.
|
|
1749
|
+
*
|
|
1750
|
+
* The RID rather than a network label: it is public infrastructure, it is
|
|
1751
|
+
* unambiguous, and it identifies the deployment without naming a customer.
|
|
1752
|
+
*/
|
|
1753
|
+
chain?: string;
|
|
1754
|
+
/** Constructor name of the thrown error, e.g. `AtbashAPIError`. */
|
|
1755
|
+
errorClass?: string;
|
|
1756
|
+
/** HTTP status, or 0 when the request never completed. */
|
|
1757
|
+
errorStatus?: number;
|
|
1758
|
+
/**
|
|
1759
|
+
* Request path the status came from, e.g. `/api/v1/judge`.
|
|
1760
|
+
*
|
|
1761
|
+
* The class alone does not say what failed: several routes answer one call
|
|
1762
|
+
* and more than one can 404, so `AtbashAPIError` cannot distinguish "this
|
|
1763
|
+
* agent is not registered" from "the chain-routing lookup did not resolve".
|
|
1764
|
+
* The path settles it.
|
|
1765
|
+
*
|
|
1766
|
+
* Carries no query string — `requestPath` strips it at the point the error
|
|
1767
|
+
* is built, because a query string carries org names, tool call ids and the
|
|
1768
|
+
* agent pubkey. Structured and already sanitised, so this stays inside the
|
|
1769
|
+
* metadata rule where an error message would not.
|
|
1770
|
+
*/
|
|
1771
|
+
errorPath?: string;
|
|
1772
|
+
/**
|
|
1773
|
+
* Short categorical result, when "success" is too coarse — e.g. a memory
|
|
1774
|
+
* write that scanned clean but never reached the chain.
|
|
1775
|
+
*
|
|
1776
|
+
* Categorical by contract: a value a caller chooses from a fixed vocabulary,
|
|
1777
|
+
* never free text and never anything derived from user content.
|
|
1778
|
+
*/
|
|
1779
|
+
outcome?: string;
|
|
1780
|
+
}
|
|
1781
|
+
/** Hashes an agent key for emission. Supplied by `setupTelemetry`. */
|
|
1782
|
+
type AgentKeyHasher = (pubkeyHex: string) => string;
|
|
1783
|
+
/**
|
|
1784
|
+
* Point this module at a logger, or at nothing.
|
|
1785
|
+
*
|
|
1786
|
+
* Called by `setupTelemetry` once the shared exporter exists, so events and
|
|
1787
|
+
* counters travel the same authenticated route and share one opt-out decision.
|
|
1788
|
+
*
|
|
1789
|
+
* @param next - Logger to emit through, or null to disable.
|
|
1790
|
+
* @param opts - Version and source stamped on every event, and the hasher
|
|
1791
|
+
* applied to the agent key. Without a hasher, the agent field is dropped.
|
|
1792
|
+
*/
|
|
1793
|
+
declare function configureEvents(next: Logger | null, opts?: {
|
|
1794
|
+
version?: string;
|
|
1795
|
+
source?: string;
|
|
1796
|
+
hashAgentKey?: AgentKeyHasher;
|
|
1797
|
+
}): void;
|
|
1798
|
+
/** True when an event would actually be emitted. Exported for tests and callers that build context lazily. */
|
|
1799
|
+
declare function eventsAreOn(): boolean;
|
|
1800
|
+
/**
|
|
1801
|
+
* Emit one wide event for a completed operation.
|
|
1802
|
+
*
|
|
1803
|
+
* Never throws and never blocks: telemetry failing must not change what the
|
|
1804
|
+
* caller observes. Does nothing when events are off.
|
|
1805
|
+
*
|
|
1806
|
+
* @param e - The completed operation.
|
|
1807
|
+
*/
|
|
1808
|
+
declare function recordEvent(e: OperationEvent): void;
|
|
1809
|
+
|
|
1666
1810
|
/**
|
|
1667
1811
|
* Rust core does the work; `browser/encrypted-toolcall.ts` mirrors it for the
|
|
1668
1812
|
* browser and must produce the same columns.
|
|
@@ -1760,4 +1904,4 @@ declare function containsSecret(text: string): boolean;
|
|
|
1760
1904
|
declare function createMemorySnapshot(entries: MemoryEntry[], takenAt: number): MemorySnapshot;
|
|
1761
1905
|
declare function diffMemorySnapshots(before: MemorySnapshot, after: MemorySnapshot): MemoryDiffResult;
|
|
1762
1906
|
|
|
1763
|
-
export { type ActionType, type AgentAuth, type AgentLookupOptions, type AgentMemoryEntry, type AgentPolicy, type AnomalySeverity, type AnomalyType, Atbash, AtbashAPIError, type AtbashLogger, type AtbashOptions, type AtbashUserConfig, BOOT_SYNC_HINT, type ChainConfig, type ChainOpts, type ClassifierToolContext, type ClassifierToolEvent, type ClassifyMemoryReadOptions, type ClassifyMemoryWriteOptions, type ClientSource, type CommitMemoryOptions, DEFAULT_BLOCKCHAIN_RID, DEFAULT_CHROMIA_NODE_URLS, DEFAULT_ENDPOINT, DEFAULT_MEMORY_PATH_PATTERNS, DEFAULT_MEMORY_READ_TOOL_NAMES, DEFAULT_MEMORY_WRITE_TOOL_NAMES, type Decision, type DecisionVerdict, EciesDomain, type EncryptedMemory, type Envelope, type FromConfigOptions, type GuardLogger, type GuardMemoryDecision, type GuardMemoryWriteInput, type GuardMemoryWriteResult, type HeldAction, type HeldActionReview, type HookDecision, HttpClient, HttpTransportError, type JudgeEndpointConfig, type JudgeOptions, type JudgeResult, type JudgmentState, type JudgmentStatus, KEY_FILENAMES, type KeyPair, type LogToolCallOptions, type LogToolCallResult, type MemoryAnomaly, type MemoryDiffResult, type MemoryEntry, MemoryGuardManager, type MemoryGuardManagerOptions, MemoryIntegrityError, type MemoryPointer, type MemoryRollbackEvent, type MemoryScanOptions, type MemoryScanResult, type MemoryScanVerdict, type MemorySnapshot, type ModifiedEntry, type Network, type OrgSubscription, PRIVATE_CHAIN, PUBLIC_CHAIN, PointerStore, type Provider, type PubkeyValue, type RedactResult, type RollbackMemoryOptions, type SecretKind, type SecretMatch, SignatureVerificationError, type Subscription, type SyncMemoryOptions, type SyncMemoryResult, type TelemetryConfig, type TierInfo, type ToolCallFull, type ToolCallInput, type ToolCallRecord, type ValidatedEndpoint, type Verdict, type WrappedLogger, bootSyncFailureLine, buildAllowedJudgeHosts, canonicalAllow, chainForNetwork, chooseKeyPath, claimHashHex, classifyMemoryRead, classifyMemoryWrite, columnAad, commitMemoryVersion, containsEvasionCharacters, containsSecret, createFileLogger, createMemoryGuardManager, createMemorySnapshot, decryptForOrg, decryptMemoryContent, defaultPluginLogPath, defaultPointerPath, deriveMemoryKey, derivePublicKey, diffMemorySnapshots, encryptForOrg, encryptMemoryContent, encryptedLength, flushTelemetry, generateKeypair, getActiveAgentMemory, getActiveMemoryId, getConfigDir, getConfigPath, getMemoryById, getMemoryHistory, getRecentAgentMemory, getRollbackHistory, guardMemoryWrite, isEnvelope, isValidPrivateKey, keyFingerprintOf, keyPathCandidates, loadAgent, loadAgentFromFile, loadUserConfig, normalizeActionForHash, normalizeActionType, normalizeForMatching, normalizeStatus, normalizeVerdict, packEnvelope, parseEnvelope, pubkeyToHex, recordCall, recordDuration, redactJsonStrings, redactSecrets, resolve, resolveKeyPath, rollbackMemory, saveUserConfig, scanMemory, scanMemoryBatch, setupTelemetry, shutdownTelemetry, signEncryptedToolCall, signJudgeAction, signLogToolCall, syncLocalMemory, validateJudgeEndpoint, verifyJudgeResponseSignature, verifySignature };
|
|
1907
|
+
export { type ActionType, type AgentAuth, type AgentLookupOptions, type AgentMemoryEntry, type AgentPolicy, type AnomalySeverity, type AnomalyType, Atbash, AtbashAPIError, type AtbashLogger, type AtbashOptions, type AtbashUserConfig, BOOT_SYNC_HINT, type ChainConfig, type ChainOpts, type ClassifierToolContext, type ClassifierToolEvent, type ClassifyMemoryReadOptions, type ClassifyMemoryWriteOptions, type ClientSource, type CommitMemoryOptions, DEFAULT_BLOCKCHAIN_RID, DEFAULT_CHROMIA_NODE_URLS, DEFAULT_ENDPOINT, DEFAULT_MEMORY_PATH_PATTERNS, DEFAULT_MEMORY_READ_TOOL_NAMES, DEFAULT_MEMORY_WRITE_TOOL_NAMES, type Decision, type DecisionVerdict, EciesDomain, type EncryptedMemory, type Envelope, type FromConfigOptions, type GuardLogger, type GuardMemoryDecision, type GuardMemoryWriteInput, type GuardMemoryWriteResult, type HeldAction, type HeldActionReview, type HookDecision, HttpClient, HttpTransportError, type JudgeEndpointConfig, type JudgeOptions, type JudgeResult, type JudgmentState, type JudgmentStatus, KEY_FILENAMES, type KeyPair, type LogToolCallOptions, type LogToolCallResult, type MemoryAnomaly, type MemoryDiffResult, type MemoryEntry, MemoryGuardManager, type MemoryGuardManagerOptions, MemoryIntegrityError, type MemoryPointer, type MemoryRollbackEvent, type MemoryScanOptions, type MemoryScanResult, type MemoryScanVerdict, type MemorySnapshot, type ModifiedEntry, type Network, type OperationEvent, type OrgSubscription, PRIVATE_CHAIN, PUBLIC_CHAIN, PointerStore, type Provider, type PubkeyValue, type RedactResult, type RollbackMemoryOptions, type SecretKind, type SecretMatch, SignatureVerificationError, type Subscription, type SyncMemoryOptions, type SyncMemoryResult, type TelemetryConfig, type TierInfo, type ToolCallFull, type ToolCallInput, type ToolCallRecord, type ValidatedEndpoint, type Verdict, type WrappedLogger, bootSyncFailureLine, buildAllowedJudgeHosts, canonicalAllow, chainForNetwork, chooseKeyPath, claimHashHex, classifyMemoryRead, classifyMemoryWrite, columnAad, commitMemoryVersion, configureEvents, containsEvasionCharacters, containsSecret, createFileLogger, createMemoryGuardManager, createMemorySnapshot, decryptForOrg, decryptMemoryContent, defaultPluginLogPath, defaultPointerPath, deriveMemoryKey, derivePublicKey, diffMemorySnapshots, encryptForOrg, encryptMemoryContent, encryptedLength, eventsAreOn, flushTelemetry, generateKeypair, getActiveAgentMemory, getActiveMemoryId, getConfigDir, getConfigPath, getMemoryById, getMemoryHistory, getRecentAgentMemory, getRollbackHistory, guardMemoryWrite, isEnvelope, isValidPrivateKey, keyFingerprintOf, keyPathCandidates, loadAgent, loadAgentFromFile, loadUserConfig, normalizeActionForHash, normalizeActionType, normalizeForMatching, normalizeStatus, normalizeVerdict, packEnvelope, parseEnvelope, pubkeyToHex, recordCall, recordDuration, recordEvent, redactJsonStrings, redactSecrets, resolve, resolveKeyPath, rollbackMemory, saveUserConfig, scanMemory, scanMemoryBatch, setupTelemetry, shutdownTelemetry, signEncryptedToolCall, signJudgeAction, signLogToolCall, syncLocalMemory, validateJudgeEndpoint, verifyJudgeResponseSignature, verifySignature };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Logger } from '@opentelemetry/api-logs';
|
|
2
|
+
|
|
1
3
|
type JudgeEndpointConfig = {
|
|
2
4
|
policy?: "default";
|
|
3
5
|
endpoint?: string;
|
|
@@ -1233,6 +1235,19 @@ interface GuardMemoryWriteResult {
|
|
|
1233
1235
|
/** Present when handled. True only after the chain transaction confirms. */
|
|
1234
1236
|
committed?: boolean;
|
|
1235
1237
|
}
|
|
1238
|
+
/**
|
|
1239
|
+
* Guard a memory write, and record what was decided.
|
|
1240
|
+
*
|
|
1241
|
+
* Wraps the decision rather than threading telemetry through its eight exits,
|
|
1242
|
+
* so a later return added inside cannot quietly stop being counted.
|
|
1243
|
+
*
|
|
1244
|
+
* Only a call this guard actually handled is recorded. A tool call that was
|
|
1245
|
+
* never a memory write is not a memory operation, and counting it would put
|
|
1246
|
+
* every unrelated edit into the number a memory migration reads.
|
|
1247
|
+
*
|
|
1248
|
+
* @param input - The tool call and the agent to judge it for.
|
|
1249
|
+
* @returns What the guard decided; unchanged by the recording.
|
|
1250
|
+
*/
|
|
1236
1251
|
declare function guardMemoryWrite(input: GuardMemoryWriteInput): Promise<GuardMemoryWriteResult>;
|
|
1237
1252
|
|
|
1238
1253
|
/**
|
|
@@ -1641,6 +1656,20 @@ interface TelemetryConfig {
|
|
|
1641
1656
|
* `{ Authorization: "Bearer <hex>" }`). Required to actually export.
|
|
1642
1657
|
*/
|
|
1643
1658
|
getAuthHeaders?: () => Record<string, string>;
|
|
1659
|
+
/**
|
|
1660
|
+
* Hashes the agent key before it is emitted on a wide event.
|
|
1661
|
+
*
|
|
1662
|
+
* Defaults to an unsalted SHA-256, which is de-identification rather than
|
|
1663
|
+
* anonymisation: agent pubkeys are public on chain and can be enumerated, so
|
|
1664
|
+
* the mapping is recoverable by anyone holding that list. Supply a salted
|
|
1665
|
+
* hasher to make it uncorrelatable, at the cost of joining across
|
|
1666
|
+
* deployments.
|
|
1667
|
+
*
|
|
1668
|
+
* Injected rather than imported so the telemetry modules need nothing from
|
|
1669
|
+
* the native addon. Left unset, the agent field is dropped from events
|
|
1670
|
+
* rather than falling back to the raw key.
|
|
1671
|
+
*/
|
|
1672
|
+
hashAgentKey?: (pubkeyHex: string) => string;
|
|
1644
1673
|
}
|
|
1645
1674
|
declare function setupTelemetry(config: TelemetryConfig): void;
|
|
1646
1675
|
/**
|
|
@@ -1663,6 +1692,121 @@ declare function flushTelemetry(): Promise<void>;
|
|
|
1663
1692
|
*/
|
|
1664
1693
|
declare function shutdownTelemetry(): Promise<void>;
|
|
1665
1694
|
|
|
1695
|
+
/**
|
|
1696
|
+
* Wide events: one row per SDK operation, alongside the counters.
|
|
1697
|
+
*
|
|
1698
|
+
* The counters in `telemetry.ts` are aggregated inside this process before
|
|
1699
|
+
* export, so Honeycomb never receives a per-operation row. That is fine for
|
|
1700
|
+
* "is it up" and useless for everything else: a question nobody attached an
|
|
1701
|
+
* attribute for in advance cannot be answered later, because the data to
|
|
1702
|
+
* answer it never existed. "Which org sees the most failures", "what preceded
|
|
1703
|
+
* a fail-closed", "is the new release slower" are all that shape.
|
|
1704
|
+
*
|
|
1705
|
+
* So each operation also emits one event carrying its whole context. The
|
|
1706
|
+
* counters stay — they are the right tool for health boards and alerts, and
|
|
1707
|
+
* they are not sampled.
|
|
1708
|
+
*
|
|
1709
|
+
* TWO RULES SHAPE THIS MODULE.
|
|
1710
|
+
*
|
|
1711
|
+
* The payload is METADATA ONLY, and the allowlist below is the whole of it:
|
|
1712
|
+
* function name, outcome, latency, error class, error status and path, SDK
|
|
1713
|
+
* version, chain, and a hash of the agent key. Action text, tool arguments, policy text, organisation
|
|
1714
|
+
* names and keys never appear — not as a field that is emptied, but as a field
|
|
1715
|
+
* that does not exist, so there is nothing to forget to strip.
|
|
1716
|
+
*
|
|
1717
|
+
* The agent key is hashed, never sent raw, and the hasher is INJECTED rather
|
|
1718
|
+
* than imported: this module needs nothing from the native addon. With no
|
|
1719
|
+
* hasher supplied the field is DROPPED rather than falling back to the raw
|
|
1720
|
+
* key, so the guarantee does not depend on wiring somebody could forget.
|
|
1721
|
+
*
|
|
1722
|
+
* NOTE on what hashing does and does not buy. Agent pubkeys are public on
|
|
1723
|
+
* chain and can be enumerated, so an UNSALTED hash is reversible by anyone who
|
|
1724
|
+
* can read the chain: it is de-identification, not anonymisation. A salted
|
|
1725
|
+
* hasher makes it uncorrelatable and costs cross-deployment joins. Which one
|
|
1726
|
+
* is wanted is the caller's decision; this module only guarantees the raw key
|
|
1727
|
+
* never leaves.
|
|
1728
|
+
*
|
|
1729
|
+
* And the richer payload has its own switch. Counters carry a function name
|
|
1730
|
+
* and a source. These events carry agent and org identity off a customer's
|
|
1731
|
+
* machine, which is a different proposition for a security product, so
|
|
1732
|
+
* `ATBASH_TELEMETRY_EVENTS_DISABLED=1` turns them off while leaving the health
|
|
1733
|
+
* counters on. Both remain subject to the existing global opt-out.
|
|
1734
|
+
*/
|
|
1735
|
+
|
|
1736
|
+
/** Attributes an event may carry. Anything not listed here cannot be emitted. */
|
|
1737
|
+
interface OperationEvent {
|
|
1738
|
+
/** SDK function, matching the counter's `function.name` so the two join. */
|
|
1739
|
+
functionName: string;
|
|
1740
|
+
durationMs: number;
|
|
1741
|
+
status: "success" | "error";
|
|
1742
|
+
/**
|
|
1743
|
+
* Hex pubkey of the agent the call was made as. Hashed before it is emitted,
|
|
1744
|
+
* and omitted entirely when no hasher is configured.
|
|
1745
|
+
*/
|
|
1746
|
+
agentPubkey?: string;
|
|
1747
|
+
/**
|
|
1748
|
+
* Blockchain RID of the chain this call concerned.
|
|
1749
|
+
*
|
|
1750
|
+
* The RID rather than a network label: it is public infrastructure, it is
|
|
1751
|
+
* unambiguous, and it identifies the deployment without naming a customer.
|
|
1752
|
+
*/
|
|
1753
|
+
chain?: string;
|
|
1754
|
+
/** Constructor name of the thrown error, e.g. `AtbashAPIError`. */
|
|
1755
|
+
errorClass?: string;
|
|
1756
|
+
/** HTTP status, or 0 when the request never completed. */
|
|
1757
|
+
errorStatus?: number;
|
|
1758
|
+
/**
|
|
1759
|
+
* Request path the status came from, e.g. `/api/v1/judge`.
|
|
1760
|
+
*
|
|
1761
|
+
* The class alone does not say what failed: several routes answer one call
|
|
1762
|
+
* and more than one can 404, so `AtbashAPIError` cannot distinguish "this
|
|
1763
|
+
* agent is not registered" from "the chain-routing lookup did not resolve".
|
|
1764
|
+
* The path settles it.
|
|
1765
|
+
*
|
|
1766
|
+
* Carries no query string — `requestPath` strips it at the point the error
|
|
1767
|
+
* is built, because a query string carries org names, tool call ids and the
|
|
1768
|
+
* agent pubkey. Structured and already sanitised, so this stays inside the
|
|
1769
|
+
* metadata rule where an error message would not.
|
|
1770
|
+
*/
|
|
1771
|
+
errorPath?: string;
|
|
1772
|
+
/**
|
|
1773
|
+
* Short categorical result, when "success" is too coarse — e.g. a memory
|
|
1774
|
+
* write that scanned clean but never reached the chain.
|
|
1775
|
+
*
|
|
1776
|
+
* Categorical by contract: a value a caller chooses from a fixed vocabulary,
|
|
1777
|
+
* never free text and never anything derived from user content.
|
|
1778
|
+
*/
|
|
1779
|
+
outcome?: string;
|
|
1780
|
+
}
|
|
1781
|
+
/** Hashes an agent key for emission. Supplied by `setupTelemetry`. */
|
|
1782
|
+
type AgentKeyHasher = (pubkeyHex: string) => string;
|
|
1783
|
+
/**
|
|
1784
|
+
* Point this module at a logger, or at nothing.
|
|
1785
|
+
*
|
|
1786
|
+
* Called by `setupTelemetry` once the shared exporter exists, so events and
|
|
1787
|
+
* counters travel the same authenticated route and share one opt-out decision.
|
|
1788
|
+
*
|
|
1789
|
+
* @param next - Logger to emit through, or null to disable.
|
|
1790
|
+
* @param opts - Version and source stamped on every event, and the hasher
|
|
1791
|
+
* applied to the agent key. Without a hasher, the agent field is dropped.
|
|
1792
|
+
*/
|
|
1793
|
+
declare function configureEvents(next: Logger | null, opts?: {
|
|
1794
|
+
version?: string;
|
|
1795
|
+
source?: string;
|
|
1796
|
+
hashAgentKey?: AgentKeyHasher;
|
|
1797
|
+
}): void;
|
|
1798
|
+
/** True when an event would actually be emitted. Exported for tests and callers that build context lazily. */
|
|
1799
|
+
declare function eventsAreOn(): boolean;
|
|
1800
|
+
/**
|
|
1801
|
+
* Emit one wide event for a completed operation.
|
|
1802
|
+
*
|
|
1803
|
+
* Never throws and never blocks: telemetry failing must not change what the
|
|
1804
|
+
* caller observes. Does nothing when events are off.
|
|
1805
|
+
*
|
|
1806
|
+
* @param e - The completed operation.
|
|
1807
|
+
*/
|
|
1808
|
+
declare function recordEvent(e: OperationEvent): void;
|
|
1809
|
+
|
|
1666
1810
|
/**
|
|
1667
1811
|
* Rust core does the work; `browser/encrypted-toolcall.ts` mirrors it for the
|
|
1668
1812
|
* browser and must produce the same columns.
|
|
@@ -1760,4 +1904,4 @@ declare function containsSecret(text: string): boolean;
|
|
|
1760
1904
|
declare function createMemorySnapshot(entries: MemoryEntry[], takenAt: number): MemorySnapshot;
|
|
1761
1905
|
declare function diffMemorySnapshots(before: MemorySnapshot, after: MemorySnapshot): MemoryDiffResult;
|
|
1762
1906
|
|
|
1763
|
-
export { type ActionType, type AgentAuth, type AgentLookupOptions, type AgentMemoryEntry, type AgentPolicy, type AnomalySeverity, type AnomalyType, Atbash, AtbashAPIError, type AtbashLogger, type AtbashOptions, type AtbashUserConfig, BOOT_SYNC_HINT, type ChainConfig, type ChainOpts, type ClassifierToolContext, type ClassifierToolEvent, type ClassifyMemoryReadOptions, type ClassifyMemoryWriteOptions, type ClientSource, type CommitMemoryOptions, DEFAULT_BLOCKCHAIN_RID, DEFAULT_CHROMIA_NODE_URLS, DEFAULT_ENDPOINT, DEFAULT_MEMORY_PATH_PATTERNS, DEFAULT_MEMORY_READ_TOOL_NAMES, DEFAULT_MEMORY_WRITE_TOOL_NAMES, type Decision, type DecisionVerdict, EciesDomain, type EncryptedMemory, type Envelope, type FromConfigOptions, type GuardLogger, type GuardMemoryDecision, type GuardMemoryWriteInput, type GuardMemoryWriteResult, type HeldAction, type HeldActionReview, type HookDecision, HttpClient, HttpTransportError, type JudgeEndpointConfig, type JudgeOptions, type JudgeResult, type JudgmentState, type JudgmentStatus, KEY_FILENAMES, type KeyPair, type LogToolCallOptions, type LogToolCallResult, type MemoryAnomaly, type MemoryDiffResult, type MemoryEntry, MemoryGuardManager, type MemoryGuardManagerOptions, MemoryIntegrityError, type MemoryPointer, type MemoryRollbackEvent, type MemoryScanOptions, type MemoryScanResult, type MemoryScanVerdict, type MemorySnapshot, type ModifiedEntry, type Network, type OrgSubscription, PRIVATE_CHAIN, PUBLIC_CHAIN, PointerStore, type Provider, type PubkeyValue, type RedactResult, type RollbackMemoryOptions, type SecretKind, type SecretMatch, SignatureVerificationError, type Subscription, type SyncMemoryOptions, type SyncMemoryResult, type TelemetryConfig, type TierInfo, type ToolCallFull, type ToolCallInput, type ToolCallRecord, type ValidatedEndpoint, type Verdict, type WrappedLogger, bootSyncFailureLine, buildAllowedJudgeHosts, canonicalAllow, chainForNetwork, chooseKeyPath, claimHashHex, classifyMemoryRead, classifyMemoryWrite, columnAad, commitMemoryVersion, containsEvasionCharacters, containsSecret, createFileLogger, createMemoryGuardManager, createMemorySnapshot, decryptForOrg, decryptMemoryContent, defaultPluginLogPath, defaultPointerPath, deriveMemoryKey, derivePublicKey, diffMemorySnapshots, encryptForOrg, encryptMemoryContent, encryptedLength, flushTelemetry, generateKeypair, getActiveAgentMemory, getActiveMemoryId, getConfigDir, getConfigPath, getMemoryById, getMemoryHistory, getRecentAgentMemory, getRollbackHistory, guardMemoryWrite, isEnvelope, isValidPrivateKey, keyFingerprintOf, keyPathCandidates, loadAgent, loadAgentFromFile, loadUserConfig, normalizeActionForHash, normalizeActionType, normalizeForMatching, normalizeStatus, normalizeVerdict, packEnvelope, parseEnvelope, pubkeyToHex, recordCall, recordDuration, redactJsonStrings, redactSecrets, resolve, resolveKeyPath, rollbackMemory, saveUserConfig, scanMemory, scanMemoryBatch, setupTelemetry, shutdownTelemetry, signEncryptedToolCall, signJudgeAction, signLogToolCall, syncLocalMemory, validateJudgeEndpoint, verifyJudgeResponseSignature, verifySignature };
|
|
1907
|
+
export { type ActionType, type AgentAuth, type AgentLookupOptions, type AgentMemoryEntry, type AgentPolicy, type AnomalySeverity, type AnomalyType, Atbash, AtbashAPIError, type AtbashLogger, type AtbashOptions, type AtbashUserConfig, BOOT_SYNC_HINT, type ChainConfig, type ChainOpts, type ClassifierToolContext, type ClassifierToolEvent, type ClassifyMemoryReadOptions, type ClassifyMemoryWriteOptions, type ClientSource, type CommitMemoryOptions, DEFAULT_BLOCKCHAIN_RID, DEFAULT_CHROMIA_NODE_URLS, DEFAULT_ENDPOINT, DEFAULT_MEMORY_PATH_PATTERNS, DEFAULT_MEMORY_READ_TOOL_NAMES, DEFAULT_MEMORY_WRITE_TOOL_NAMES, type Decision, type DecisionVerdict, EciesDomain, type EncryptedMemory, type Envelope, type FromConfigOptions, type GuardLogger, type GuardMemoryDecision, type GuardMemoryWriteInput, type GuardMemoryWriteResult, type HeldAction, type HeldActionReview, type HookDecision, HttpClient, HttpTransportError, type JudgeEndpointConfig, type JudgeOptions, type JudgeResult, type JudgmentState, type JudgmentStatus, KEY_FILENAMES, type KeyPair, type LogToolCallOptions, type LogToolCallResult, type MemoryAnomaly, type MemoryDiffResult, type MemoryEntry, MemoryGuardManager, type MemoryGuardManagerOptions, MemoryIntegrityError, type MemoryPointer, type MemoryRollbackEvent, type MemoryScanOptions, type MemoryScanResult, type MemoryScanVerdict, type MemorySnapshot, type ModifiedEntry, type Network, type OperationEvent, type OrgSubscription, PRIVATE_CHAIN, PUBLIC_CHAIN, PointerStore, type Provider, type PubkeyValue, type RedactResult, type RollbackMemoryOptions, type SecretKind, type SecretMatch, SignatureVerificationError, type Subscription, type SyncMemoryOptions, type SyncMemoryResult, type TelemetryConfig, type TierInfo, type ToolCallFull, type ToolCallInput, type ToolCallRecord, type ValidatedEndpoint, type Verdict, type WrappedLogger, bootSyncFailureLine, buildAllowedJudgeHosts, canonicalAllow, chainForNetwork, chooseKeyPath, claimHashHex, classifyMemoryRead, classifyMemoryWrite, columnAad, commitMemoryVersion, configureEvents, containsEvasionCharacters, containsSecret, createFileLogger, createMemoryGuardManager, createMemorySnapshot, decryptForOrg, decryptMemoryContent, defaultPluginLogPath, defaultPointerPath, deriveMemoryKey, derivePublicKey, diffMemorySnapshots, encryptForOrg, encryptMemoryContent, encryptedLength, eventsAreOn, flushTelemetry, generateKeypair, getActiveAgentMemory, getActiveMemoryId, getConfigDir, getConfigPath, getMemoryById, getMemoryHistory, getRecentAgentMemory, getRollbackHistory, guardMemoryWrite, isEnvelope, isValidPrivateKey, keyFingerprintOf, keyPathCandidates, loadAgent, loadAgentFromFile, loadUserConfig, normalizeActionForHash, normalizeActionType, normalizeForMatching, normalizeStatus, normalizeVerdict, packEnvelope, parseEnvelope, pubkeyToHex, recordCall, recordDuration, recordEvent, redactJsonStrings, redactSecrets, resolve, resolveKeyPath, rollbackMemory, saveUserConfig, scanMemory, scanMemoryBatch, setupTelemetry, shutdownTelemetry, signEncryptedToolCall, signJudgeAction, signLogToolCall, syncLocalMemory, validateJudgeEndpoint, verifyJudgeResponseSignature, verifySignature };
|