@atbash/sdk 0.8.0-dev.0 → 0.10.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/dist/index.d.mts CHANGED
@@ -608,8 +608,8 @@ declare function decryptMemoryContent(ciphertext: Buffer, nonce: Buffer, key: Bu
608
608
  * Scan a single memory entry for poisoning.
609
609
  *
610
610
  * `auth` is the agent that signs the on-chain audit log for the
611
- * LLM-judge call. The LLM is authoritative; unicode-evasion presence
612
- * is surfaced to the prompt so the LLM can weight suspicion accordingly.
611
+ * LLM-judge call. Unicode-evasion presence is surfaced to the prompt
612
+ * so the LLM can weight suspicion accordingly.
613
613
  */
614
614
  declare function scanMemory(entry: MemoryEntry, auth: AgentAuth, opts?: MemoryScanOptions): Promise<MemoryScanResult>;
615
615
  /**
@@ -640,9 +640,7 @@ interface RollbackMemoryOptions {
640
640
  * deactivated on-chain.
641
641
  *
642
642
  * The caller is responsible for running `scanMemory` first when
643
- * appropriate — this function does not gate on the verdict. The
644
- * `score` parameter is the only metadata that flows in alongside
645
- * the ciphertext.
643
+ * appropriate — this function does not gate on the verdict.
646
644
  */
647
645
  declare function commitMemoryVersion(plaintext: string, auth: AgentAuth, opts?: CommitMemoryOptions): Promise<void>;
648
646
  /**
@@ -674,35 +672,28 @@ interface MemoryRollbackEvent {
674
672
  * Cheap version-pointer probe. Returns just the id of the current
675
673
  * active memory (or null if none). No ciphertext is transferred — the
676
674
  * response is a single integer, so this is safe to call on every
677
- * memory-read hot path. Callers that hold a decrypted local copy can
678
- * compare against a stored pointer and only refetch the full row via
679
- * `getActiveMemory` when the id has changed.
675
+ * memory-read hot path.
680
676
  */
681
677
  declare function getActiveMemoryId(auth: AgentAuth, chainOpts?: ChainOpts): Promise<number | null>;
682
678
  /**
683
679
  * Recent active memory entries — subset of active versions filtered
684
- * by the chain's `MEMORY_RECENT_WINDOW_MS` (10 days at time of
685
- * writing). Intended for prompt injection at agent runtime, where
686
- * stale memory is worse than missing memory. For a time-unbounded
687
- * view of every currently active version, use `getAllAgentMemory`.
680
+ * by the chain's `MEMORY_RECENT_WINDOW_MS`. For a time-unbounded view
681
+ * of every currently active version, use `getAllAgentMemory`.
688
682
  */
689
683
  declare function getActiveMemory(auth: AgentAuth, chainOpts?: ChainOpts): Promise<AgentMemoryEntry[]>;
690
684
  /**
691
685
  * All currently-active memory entries with no time cutoff. Use this
692
- * when you need every active version regardless of age — e.g., a
693
- * dashboard listing, or a long-running agent whose oldest active
694
- * versions may have fallen outside `getActiveMemory`'s recent window.
686
+ * when you need every active version regardless of age.
695
687
  */
696
688
  declare function getAllAgentMemory(auth: AgentAuth, chainOpts?: ChainOpts): Promise<AgentMemoryEntry[]>;
697
689
  /**
698
- * Full version history — active + inactive, most recent first.
699
- * Used by rollback UX to choose a target version.
690
+ * Full version history — active + inactive, most recent first. Used
691
+ * by rollback UX to choose a target version.
700
692
  */
701
693
  declare function getMemoryHistory(auth: AgentAuth, chainOpts?: ChainOpts): Promise<AgentMemoryEntry[]>;
702
694
  /**
703
695
  * Fetch a single memory entry by version id, including its current
704
- * `is_active` state. Useful for inspecting a historical version
705
- * before rolling back to it.
696
+ * `is_active` state.
706
697
  */
707
698
  declare function getMemoryById(id: number, auth: AgentAuth, chainOpts?: ChainOpts): Promise<AgentMemoryEntry>;
708
699
  /**
@@ -716,29 +707,15 @@ declare function getRollbackHistory(auth: AgentAuth, chainOpts?: ChainOpts): Pro
716
707
  */
717
708
  declare function rollbackMemory(toId: number, reason: string, auth: AgentAuth, opts?: RollbackMemoryOptions): Promise<void>;
718
709
 
719
- /**
720
- * Classify a plugin tool-call event as a memory write.
721
- *
722
- * Plugins receive `before_tool_call` events from their host runtime
723
- * (openclaw, Claude API, MCP, etc.) with varying argument shapes. This
724
- * module normalizes across shapes and returns a `MemoryEntry` when the
725
- * call is writing to a memory-like path, or `null` when the SDK should
726
- * skip the memory-scan path entirely.
727
- *
728
- * `event` and `ctx` are typed `unknown` so any plugin can pass its
729
- * native hook payloads without adaptation — the classifier probes
730
- * common key names at runtime.
731
- */
732
-
733
710
  /**
734
711
  * Tool names that indicate a memory write. Lowercase — matched
735
- * case-insensitively so both OpenClaw (lowercase) and Claude API
736
- * family (TitleCase) hit.
712
+ * case-insensitively so OpenClaw (lowercase) and Claude API family
713
+ * (TitleCase) both hit.
737
714
  */
738
715
  declare const DEFAULT_MEMORY_WRITE_TOOL_NAMES: ReadonlyArray<string>;
739
716
  /**
740
717
  * File path substrings that indicate a memory-shaped target. Callers
741
- * can extend or override this list via `classifyMemoryWrite` options.
718
+ * extend or override via `classifyMemoryWrite` options.
742
719
  */
743
720
  declare const DEFAULT_MEMORY_PATH_PATTERNS: ReadonlyArray<string>;
744
721
  /**
@@ -934,7 +911,7 @@ declare function createFileLogger(filePath: string, upstream?: UpstreamLogger):
934
911
  /** Default log-file location — `<workspaceDir>/.atbash/plugin.log`. */
935
912
  declare function defaultPluginLogPath(workspaceDir?: string): string;
936
913
 
937
- /** Dedicated memory-read tool names, matched case-insensitively. Extend via options. */
914
+ /** Dedicated memory-read tool names, matched case-insensitively. */
938
915
  declare const DEFAULT_MEMORY_READ_TOOL_NAMES: ReadonlyArray<string>;
939
916
  interface ClassifyMemoryReadOptions {
940
917
  /** Tool names that always count as memory reads. Merged with defaults. */
@@ -948,6 +925,10 @@ interface ClassifyMemoryReadOptions {
948
925
  * Returns `true` when this tool call is a memory read — either a
949
926
  * dedicated memory-read tool from `readToolNames`, or a generic read
950
927
  * tool (`read` / `read_file`) targeting a memory-shaped path.
928
+ *
929
+ * Caller-supplied `patterns` are MERGED with the defaults (matches
930
+ * Node's original behavior — extending in one plugin doesn't disable
931
+ * standard coverage).
951
932
  */
952
933
  declare function classifyMemoryRead(event: unknown, ctx: unknown, opts?: ClassifyMemoryReadOptions): boolean;
953
934
 
@@ -1069,18 +1050,9 @@ declare function shutdownTelemetry(): Promise<void>;
1069
1050
 
1070
1051
  /**
1071
1052
  * Signs `log_encrypted_tool_call` — the ciphertext-only counterpart of
1072
- * `log_tool_call`.
1073
- *
1074
- * Why this is not in the Rust core like the other signing helpers: the operation
1075
- * takes a `byte_array` argument, and the only consumer today is the dashboard,
1076
- * which loads the browser bundle where Rust is unreachable by construction. This
1077
- * module is plain TypeScript so the node and browser builds share one
1078
- * implementation and cannot drift. The Rust core gets the same operation when the
1079
- * native/Python/Go callers need it — the wire format is pinned by `crypto/ecies.ts`.
1080
- *
1081
- * The contract refuses plaintext once an org registers an encryption key
1082
- * (`log_tool_call` → "Organization requires encrypted payloads"), so for those
1083
- * orgs this is the only way to log a tool call at all.
1053
+ * `log_tool_call`. Rust core owns the encrypt + hash + GTX sign flow;
1054
+ * this module is a thin wrapper. Browser callers get the pure-TS shim
1055
+ * at `src-ts/browser/encrypted-toolcall.ts` (NAPI can't run in-browser).
1084
1056
  */
1085
1057
  /** Plaintext fields of a tool call, sealed into a single ECIES payload. */
1086
1058
  interface ToolCallPlaintext {
@@ -1090,91 +1062,39 @@ interface ToolCallPlaintext {
1090
1062
  tool_args_json: string;
1091
1063
  }
1092
1064
  /**
1093
- * Canonical form of an action for the retry-cache hash.
1094
- *
1095
- * Must stay identical to `normalizeActionForHash` in the dashboard
1096
- * (`src/lib/api/judge/on-chain.ts`): both write the same
1097
- * `tool_call_log.normalized_action_hash` column, and `get_resolved_hold_by_action_hash`
1098
- * matches a YELLOW hold retry against it. Diverging here silently breaks
1099
- * hold resolution rather than failing loudly.
1065
+ * Canonical form of an action for the retry-cache hash. Byte-identical to
1066
+ * the dashboard's `normalizeActionForHash` — diverging silently breaks
1067
+ * YELLOW-hold retry resolution.
1100
1068
  */
1101
1069
  declare function normalizeActionForHash(action: string): string;
1102
1070
  /**
1103
- * Sign a `log_encrypted_tool_call` operation.
1104
- *
1105
- * Everything the agent did action, context, tool name and args — goes into a
1106
- * single ECIES payload readable only with the org's private key. Nothing
1107
- * identifying the action is left in the operation arguments, which are permanent
1108
- * block data.
1109
- *
1110
- * `actionHash` is the one exception, and it is deliberate: it is a SHA-256 over
1111
- * the normalized action, so the chain can match a held action against its retry
1112
- * without being able to read it.
1113
- *
1114
- * @returns hex-encoded signed transaction, ready to POST as `signed_log_tool_call`.
1071
+ * Signed commitment to the plaintext claims the caller sends alongside the
1072
+ * ciphertext. The judge reads plaintext from the request body but holds no
1073
+ * org key; this hash lets it verify body-vs-ciphertext without decrypting.
1074
+ * Byte-identical to the dashboard's `claimHashHex`.
1115
1075
  */
1116
- declare function signEncryptedToolCall(toolCallId: string, action: string, context: string, toolName: string, toolArgsJson: string, orgEncryptionPubKey: string, privkeyHex: string, blockchainRidHex: string): string;
1117
-
1076
+ declare function claimHashHex(toolName: string, action: string, context: string, toolArgsJson: string): string;
1118
1077
  /**
1119
- * ECIES over secp256k1 encrypts on-chain payloads to an organization's public key.
1120
- *
1121
- * Only the holder of the org's private key can decrypt. Everyone else — including
1122
- * anyone querying the Chromia node directly, and Atbash itself — sees ciphertext.
1123
- * The recipient key is a dedicated encryption keypair the org generates in the
1124
- * dashboard and registers via `org_set_encryption_key`; it is read back with the
1125
- * `get_org_encryption_pubkey` query.
1126
- *
1127
- * ─── WIRE FORMAT (normative) ────────────────────────────────────────────────
1128
- * This exact layout is mirrored in the Atbash dashboard
1129
- * (`src/lib/chromia/ecies.ts`) and must stay byte-for-byte identical: the SDK
1130
- * encrypts tool calls, the dashboard decrypts them.
1131
- *
1132
- * version 1 byte = 0x01
1133
- * ephemeral_pubkey 33 bytes compressed secp256k1 point
1134
- * nonce 12 bytes random, per message
1135
- * ciphertext+tag N bytes AES-256-GCM output (16-byte tag appended)
1136
- *
1137
- * Version 0x01 is FROZEN, not provisional. Records encrypted under it already
1138
- * exist on the deployed chains, and the ledger is immutable — redefining 0x01
1139
- * would make them permanently unreadable, not merely stale. Evolving the format
1140
- * means emitting a NEW version byte and keeping a 0x01 decrypt path, in both
1141
- * repos, forever.
1142
- *
1143
- * Raw bytes, not base64: the on-chain columns are `byte_array`, so encoding to
1144
- * text would add ~33% to what are the largest columns in the schema.
1145
- *
1146
- * Key agreement, per message:
1147
- * shared_x = ECDH(ephemeral_privkey, org_pubkey).x // 32 bytes
1148
- * key = HKDF-SHA256(ikm=shared_x, salt=ephemeral_pubkey, info=domain, len=32)
1149
- * aad = "<domain>|<record_id>"
1150
- *
1151
- * A fresh ephemeral keypair is generated for every message and its private half is
1152
- * discarded immediately. This is what makes the scheme forward-secret with respect
1153
- * to the *sender*: leaking an agent's long-term signing key later does not expose
1154
- * anything it encrypted in the past. (Deriving the shared secret from the agent's
1155
- * static key instead would let anyone recompute every past shared secret, since the
1156
- * org's public key is public by definition.)
1157
- *
1158
- * Three separate bindings, each closing a different substitution:
1159
- * salt = ephemeral pubkey — ties the key to this exact handshake
1160
- * info = domain — a verdict payload cannot be read as a tool call
1161
- * aad = domain|record_id — a payload cannot be lifted onto another row
1078
+ * Build + sign a `log_encrypted_tool_call` transaction. Returns hex-encoded
1079
+ * signed tx, ready to POST as `signed_log_tool_call`.
1162
1080
  */
1081
+ declare function signEncryptedToolCall(toolCallId: string, action: string, context: string, toolName: string, toolArgsJson: string, orgEncryptionPubKey: string, privkeyHex: string, blockchainRidHex: string): string;
1082
+
1163
1083
  /**
1164
- * Cryptographic domain per payload kind. Fed to HKDF `info`, so each kind derives
1165
- * a different key from the same handshake — a verdict payload handed to the
1166
- * tool-call reader fails authentication rather than decoding to an empty struct.
1084
+ * Cryptographic domain per payload kind. Each kind derives a distinct
1085
+ * key from the same handshake — a verdict payload handed to the
1086
+ * tool-call reader fails authentication rather than silently decoding.
1167
1087
  *
1168
- * Must match `EciesDomain` in the dashboard's src/lib/chromia/ecies.ts exactly:
1169
- * the string is an input to key derivation, so any difference makes the two sides
1170
- * mutually unreadable.
1088
+ * Values here are the SHORT domain names the Rust core recognizes.
1089
+ * The full HKDF `info` strings (`atbash:chain-encryption:v1:<kind>`)
1090
+ * live inside the core and never surface at the API boundary.
1171
1091
  */
1172
1092
  declare const EciesDomain: {
1173
- readonly toolCall: "atbash:chain-encryption:v1:toolcall";
1174
- readonly verdict: "atbash:chain-encryption:v1:verdict";
1175
- readonly note: "atbash:chain-encryption:v1:note";
1176
- readonly policy: "atbash:chain-encryption:v1:policy";
1177
- readonly raw: "atbash:chain-encryption:v1:raw";
1093
+ readonly toolCall: "toolcall";
1094
+ readonly verdict: "verdict";
1095
+ readonly note: "note";
1096
+ readonly policy: "policy";
1097
+ readonly raw: "raw";
1178
1098
  };
1179
1099
  type EciesDomain = (typeof EciesDomain)[keyof typeof EciesDomain];
1180
1100
  /**
@@ -1189,9 +1109,9 @@ declare function encryptForOrg(plaintext: string, orgPubKeyHex: string, aad: str
1189
1109
  /**
1190
1110
  * Decrypt a payload produced by {@link encryptForOrg}.
1191
1111
  *
1192
- * Throws if the key is wrong, the `aad` does not match the one used at encrypt
1193
- * time, or the ciphertext was tampered with — GCM authentication makes all three
1194
- * indistinguishable by design.
1112
+ * Throws if the key is wrong, the `aad` does not match the one used at
1113
+ * encrypt time, or the ciphertext was tampered with — GCM authentication
1114
+ * makes all three indistinguishable by design.
1195
1115
  *
1196
1116
  * @param payload Value read from the on-chain `byte_array` column.
1197
1117
  * @param orgPrivKeyHex Org's secp256k1 private key (32 bytes hex).
@@ -1199,9 +1119,10 @@ declare function encryptForOrg(plaintext: string, orgPubKeyHex: string, aad: str
1199
1119
  */
1200
1120
  declare function decryptForOrg(payload: Uint8Array, orgPrivKeyHex: string, aad: string, domain?: EciesDomain): string;
1201
1121
  /**
1202
- * Size in bytes of the encrypted payload for a given plaintext length. Lets
1203
- * callers check against the on-chain column cap (MAX_CONTENT_CIPHER_SIZE)
1204
- * before submitting a transaction the contract would reject.
1122
+ * Size in bytes of the encrypted payload for a given plaintext length.
1123
+ * Lets callers check against the on-chain column cap
1124
+ * (`MAX_CONTENT_CIPHER_SIZE`) before submitting a transaction the
1125
+ * contract would reject.
1205
1126
  */
1206
1127
  declare function encryptedLength(plaintextByteLength: number): number;
1207
1128
 
@@ -1220,4 +1141,4 @@ declare function containsSecret(text: string): boolean;
1220
1141
  declare function createMemorySnapshot(entries: MemoryEntry[], takenAt: number): MemorySnapshot;
1221
1142
  declare function diffMemorySnapshots(before: MemorySnapshot, after: MemorySnapshot): MemoryDiffResult;
1222
1143
 
1223
- export { type ActionType, type AgentAuth, type AgentMemoryEntry, type AgentPolicy, type AnomalySeverity, type AnomalyType, Atbash, AtbashAPIError, type AtbashLogger, type AtbashOptions, type AtbashUserConfig, 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 FromConfigOptions, type GuardLogger, type GuardMemoryDecision, type GuardMemoryWriteInput, type GuardMemoryWriteResult, type HeldAction, type HeldActionReview, type HookDecision, type JudgeEndpointConfig, type JudgeOptions, type JudgeResult, type JudgmentState, type JudgmentStatus, 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, 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 ToolCallPlaintext, type ToolCallRecord, type ValidatedEndpoint, type Verdict, type WrappedLogger, classifyMemoryRead, classifyMemoryWrite, commitMemoryVersion, containsEvasionCharacters, containsSecret, createFileLogger, createMemoryGuardManager, createMemorySnapshot, decryptForOrg, decryptMemoryContent, defaultPluginLogPath, defaultPointerPath, deriveMemoryKey, derivePublicKey, diffMemorySnapshots, encryptForOrg, encryptMemoryContent, encryptedLength, flushTelemetry, generateKeypair, getActiveMemory, getActiveMemoryId, getAllAgentMemory, getConfigDir, getConfigPath, getMemoryById, getMemoryHistory, getRollbackHistory, guardMemoryWrite, isValidPrivateKey, loadAgent, loadAgentFromFile, loadUserConfig, normalizeActionForHash, normalizeForMatching, normalizeStatus, normalizeVerdict, pubkeyToHex, recordCall, recordDuration, redactJsonStrings, redactSecrets, resolve, resolveKeyPath, rollbackMemory, saveUserConfig, scanMemory, scanMemoryBatch, setupTelemetry, shutdownTelemetry, signEncryptedToolCall, signJudgeAction, signLogToolCall, syncLocalMemory, validateJudgeEndpoint, verifyJudgeResponseSignature, verifySignature };
1144
+ export { type ActionType, type AgentAuth, type AgentMemoryEntry, type AgentPolicy, type AnomalySeverity, type AnomalyType, Atbash, AtbashAPIError, type AtbashLogger, type AtbashOptions, type AtbashUserConfig, 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 FromConfigOptions, type GuardLogger, type GuardMemoryDecision, type GuardMemoryWriteInput, type GuardMemoryWriteResult, type HeldAction, type HeldActionReview, type HookDecision, type JudgeEndpointConfig, type JudgeOptions, type JudgeResult, type JudgmentState, type JudgmentStatus, 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, 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 ToolCallPlaintext, type ToolCallRecord, type ValidatedEndpoint, type Verdict, type WrappedLogger, claimHashHex, classifyMemoryRead, classifyMemoryWrite, commitMemoryVersion, containsEvasionCharacters, containsSecret, createFileLogger, createMemoryGuardManager, createMemorySnapshot, decryptForOrg, decryptMemoryContent, defaultPluginLogPath, defaultPointerPath, deriveMemoryKey, derivePublicKey, diffMemorySnapshots, encryptForOrg, encryptMemoryContent, encryptedLength, flushTelemetry, generateKeypair, getActiveMemory, getActiveMemoryId, getAllAgentMemory, getConfigDir, getConfigPath, getMemoryById, getMemoryHistory, getRollbackHistory, guardMemoryWrite, isValidPrivateKey, loadAgent, loadAgentFromFile, loadUserConfig, normalizeActionForHash, normalizeForMatching, normalizeStatus, normalizeVerdict, pubkeyToHex, recordCall, recordDuration, redactJsonStrings, redactSecrets, resolve, resolveKeyPath, rollbackMemory, saveUserConfig, scanMemory, scanMemoryBatch, setupTelemetry, shutdownTelemetry, signEncryptedToolCall, signJudgeAction, signLogToolCall, syncLocalMemory, validateJudgeEndpoint, verifyJudgeResponseSignature, verifySignature };
package/dist/index.d.ts CHANGED
@@ -608,8 +608,8 @@ declare function decryptMemoryContent(ciphertext: Buffer, nonce: Buffer, key: Bu
608
608
  * Scan a single memory entry for poisoning.
609
609
  *
610
610
  * `auth` is the agent that signs the on-chain audit log for the
611
- * LLM-judge call. The LLM is authoritative; unicode-evasion presence
612
- * is surfaced to the prompt so the LLM can weight suspicion accordingly.
611
+ * LLM-judge call. Unicode-evasion presence is surfaced to the prompt
612
+ * so the LLM can weight suspicion accordingly.
613
613
  */
614
614
  declare function scanMemory(entry: MemoryEntry, auth: AgentAuth, opts?: MemoryScanOptions): Promise<MemoryScanResult>;
615
615
  /**
@@ -640,9 +640,7 @@ interface RollbackMemoryOptions {
640
640
  * deactivated on-chain.
641
641
  *
642
642
  * The caller is responsible for running `scanMemory` first when
643
- * appropriate — this function does not gate on the verdict. The
644
- * `score` parameter is the only metadata that flows in alongside
645
- * the ciphertext.
643
+ * appropriate — this function does not gate on the verdict.
646
644
  */
647
645
  declare function commitMemoryVersion(plaintext: string, auth: AgentAuth, opts?: CommitMemoryOptions): Promise<void>;
648
646
  /**
@@ -674,35 +672,28 @@ interface MemoryRollbackEvent {
674
672
  * Cheap version-pointer probe. Returns just the id of the current
675
673
  * active memory (or null if none). No ciphertext is transferred — the
676
674
  * response is a single integer, so this is safe to call on every
677
- * memory-read hot path. Callers that hold a decrypted local copy can
678
- * compare against a stored pointer and only refetch the full row via
679
- * `getActiveMemory` when the id has changed.
675
+ * memory-read hot path.
680
676
  */
681
677
  declare function getActiveMemoryId(auth: AgentAuth, chainOpts?: ChainOpts): Promise<number | null>;
682
678
  /**
683
679
  * Recent active memory entries — subset of active versions filtered
684
- * by the chain's `MEMORY_RECENT_WINDOW_MS` (10 days at time of
685
- * writing). Intended for prompt injection at agent runtime, where
686
- * stale memory is worse than missing memory. For a time-unbounded
687
- * view of every currently active version, use `getAllAgentMemory`.
680
+ * by the chain's `MEMORY_RECENT_WINDOW_MS`. For a time-unbounded view
681
+ * of every currently active version, use `getAllAgentMemory`.
688
682
  */
689
683
  declare function getActiveMemory(auth: AgentAuth, chainOpts?: ChainOpts): Promise<AgentMemoryEntry[]>;
690
684
  /**
691
685
  * All currently-active memory entries with no time cutoff. Use this
692
- * when you need every active version regardless of age — e.g., a
693
- * dashboard listing, or a long-running agent whose oldest active
694
- * versions may have fallen outside `getActiveMemory`'s recent window.
686
+ * when you need every active version regardless of age.
695
687
  */
696
688
  declare function getAllAgentMemory(auth: AgentAuth, chainOpts?: ChainOpts): Promise<AgentMemoryEntry[]>;
697
689
  /**
698
- * Full version history — active + inactive, most recent first.
699
- * Used by rollback UX to choose a target version.
690
+ * Full version history — active + inactive, most recent first. Used
691
+ * by rollback UX to choose a target version.
700
692
  */
701
693
  declare function getMemoryHistory(auth: AgentAuth, chainOpts?: ChainOpts): Promise<AgentMemoryEntry[]>;
702
694
  /**
703
695
  * Fetch a single memory entry by version id, including its current
704
- * `is_active` state. Useful for inspecting a historical version
705
- * before rolling back to it.
696
+ * `is_active` state.
706
697
  */
707
698
  declare function getMemoryById(id: number, auth: AgentAuth, chainOpts?: ChainOpts): Promise<AgentMemoryEntry>;
708
699
  /**
@@ -716,29 +707,15 @@ declare function getRollbackHistory(auth: AgentAuth, chainOpts?: ChainOpts): Pro
716
707
  */
717
708
  declare function rollbackMemory(toId: number, reason: string, auth: AgentAuth, opts?: RollbackMemoryOptions): Promise<void>;
718
709
 
719
- /**
720
- * Classify a plugin tool-call event as a memory write.
721
- *
722
- * Plugins receive `before_tool_call` events from their host runtime
723
- * (openclaw, Claude API, MCP, etc.) with varying argument shapes. This
724
- * module normalizes across shapes and returns a `MemoryEntry` when the
725
- * call is writing to a memory-like path, or `null` when the SDK should
726
- * skip the memory-scan path entirely.
727
- *
728
- * `event` and `ctx` are typed `unknown` so any plugin can pass its
729
- * native hook payloads without adaptation — the classifier probes
730
- * common key names at runtime.
731
- */
732
-
733
710
  /**
734
711
  * Tool names that indicate a memory write. Lowercase — matched
735
- * case-insensitively so both OpenClaw (lowercase) and Claude API
736
- * family (TitleCase) hit.
712
+ * case-insensitively so OpenClaw (lowercase) and Claude API family
713
+ * (TitleCase) both hit.
737
714
  */
738
715
  declare const DEFAULT_MEMORY_WRITE_TOOL_NAMES: ReadonlyArray<string>;
739
716
  /**
740
717
  * File path substrings that indicate a memory-shaped target. Callers
741
- * can extend or override this list via `classifyMemoryWrite` options.
718
+ * extend or override via `classifyMemoryWrite` options.
742
719
  */
743
720
  declare const DEFAULT_MEMORY_PATH_PATTERNS: ReadonlyArray<string>;
744
721
  /**
@@ -934,7 +911,7 @@ declare function createFileLogger(filePath: string, upstream?: UpstreamLogger):
934
911
  /** Default log-file location — `<workspaceDir>/.atbash/plugin.log`. */
935
912
  declare function defaultPluginLogPath(workspaceDir?: string): string;
936
913
 
937
- /** Dedicated memory-read tool names, matched case-insensitively. Extend via options. */
914
+ /** Dedicated memory-read tool names, matched case-insensitively. */
938
915
  declare const DEFAULT_MEMORY_READ_TOOL_NAMES: ReadonlyArray<string>;
939
916
  interface ClassifyMemoryReadOptions {
940
917
  /** Tool names that always count as memory reads. Merged with defaults. */
@@ -948,6 +925,10 @@ interface ClassifyMemoryReadOptions {
948
925
  * Returns `true` when this tool call is a memory read — either a
949
926
  * dedicated memory-read tool from `readToolNames`, or a generic read
950
927
  * tool (`read` / `read_file`) targeting a memory-shaped path.
928
+ *
929
+ * Caller-supplied `patterns` are MERGED with the defaults (matches
930
+ * Node's original behavior — extending in one plugin doesn't disable
931
+ * standard coverage).
951
932
  */
952
933
  declare function classifyMemoryRead(event: unknown, ctx: unknown, opts?: ClassifyMemoryReadOptions): boolean;
953
934
 
@@ -1069,18 +1050,9 @@ declare function shutdownTelemetry(): Promise<void>;
1069
1050
 
1070
1051
  /**
1071
1052
  * Signs `log_encrypted_tool_call` — the ciphertext-only counterpart of
1072
- * `log_tool_call`.
1073
- *
1074
- * Why this is not in the Rust core like the other signing helpers: the operation
1075
- * takes a `byte_array` argument, and the only consumer today is the dashboard,
1076
- * which loads the browser bundle where Rust is unreachable by construction. This
1077
- * module is plain TypeScript so the node and browser builds share one
1078
- * implementation and cannot drift. The Rust core gets the same operation when the
1079
- * native/Python/Go callers need it — the wire format is pinned by `crypto/ecies.ts`.
1080
- *
1081
- * The contract refuses plaintext once an org registers an encryption key
1082
- * (`log_tool_call` → "Organization requires encrypted payloads"), so for those
1083
- * orgs this is the only way to log a tool call at all.
1053
+ * `log_tool_call`. Rust core owns the encrypt + hash + GTX sign flow;
1054
+ * this module is a thin wrapper. Browser callers get the pure-TS shim
1055
+ * at `src-ts/browser/encrypted-toolcall.ts` (NAPI can't run in-browser).
1084
1056
  */
1085
1057
  /** Plaintext fields of a tool call, sealed into a single ECIES payload. */
1086
1058
  interface ToolCallPlaintext {
@@ -1090,91 +1062,39 @@ interface ToolCallPlaintext {
1090
1062
  tool_args_json: string;
1091
1063
  }
1092
1064
  /**
1093
- * Canonical form of an action for the retry-cache hash.
1094
- *
1095
- * Must stay identical to `normalizeActionForHash` in the dashboard
1096
- * (`src/lib/api/judge/on-chain.ts`): both write the same
1097
- * `tool_call_log.normalized_action_hash` column, and `get_resolved_hold_by_action_hash`
1098
- * matches a YELLOW hold retry against it. Diverging here silently breaks
1099
- * hold resolution rather than failing loudly.
1065
+ * Canonical form of an action for the retry-cache hash. Byte-identical to
1066
+ * the dashboard's `normalizeActionForHash` — diverging silently breaks
1067
+ * YELLOW-hold retry resolution.
1100
1068
  */
1101
1069
  declare function normalizeActionForHash(action: string): string;
1102
1070
  /**
1103
- * Sign a `log_encrypted_tool_call` operation.
1104
- *
1105
- * Everything the agent did action, context, tool name and args — goes into a
1106
- * single ECIES payload readable only with the org's private key. Nothing
1107
- * identifying the action is left in the operation arguments, which are permanent
1108
- * block data.
1109
- *
1110
- * `actionHash` is the one exception, and it is deliberate: it is a SHA-256 over
1111
- * the normalized action, so the chain can match a held action against its retry
1112
- * without being able to read it.
1113
- *
1114
- * @returns hex-encoded signed transaction, ready to POST as `signed_log_tool_call`.
1071
+ * Signed commitment to the plaintext claims the caller sends alongside the
1072
+ * ciphertext. The judge reads plaintext from the request body but holds no
1073
+ * org key; this hash lets it verify body-vs-ciphertext without decrypting.
1074
+ * Byte-identical to the dashboard's `claimHashHex`.
1115
1075
  */
1116
- declare function signEncryptedToolCall(toolCallId: string, action: string, context: string, toolName: string, toolArgsJson: string, orgEncryptionPubKey: string, privkeyHex: string, blockchainRidHex: string): string;
1117
-
1076
+ declare function claimHashHex(toolName: string, action: string, context: string, toolArgsJson: string): string;
1118
1077
  /**
1119
- * ECIES over secp256k1 encrypts on-chain payloads to an organization's public key.
1120
- *
1121
- * Only the holder of the org's private key can decrypt. Everyone else — including
1122
- * anyone querying the Chromia node directly, and Atbash itself — sees ciphertext.
1123
- * The recipient key is a dedicated encryption keypair the org generates in the
1124
- * dashboard and registers via `org_set_encryption_key`; it is read back with the
1125
- * `get_org_encryption_pubkey` query.
1126
- *
1127
- * ─── WIRE FORMAT (normative) ────────────────────────────────────────────────
1128
- * This exact layout is mirrored in the Atbash dashboard
1129
- * (`src/lib/chromia/ecies.ts`) and must stay byte-for-byte identical: the SDK
1130
- * encrypts tool calls, the dashboard decrypts them.
1131
- *
1132
- * version 1 byte = 0x01
1133
- * ephemeral_pubkey 33 bytes compressed secp256k1 point
1134
- * nonce 12 bytes random, per message
1135
- * ciphertext+tag N bytes AES-256-GCM output (16-byte tag appended)
1136
- *
1137
- * Version 0x01 is FROZEN, not provisional. Records encrypted under it already
1138
- * exist on the deployed chains, and the ledger is immutable — redefining 0x01
1139
- * would make them permanently unreadable, not merely stale. Evolving the format
1140
- * means emitting a NEW version byte and keeping a 0x01 decrypt path, in both
1141
- * repos, forever.
1142
- *
1143
- * Raw bytes, not base64: the on-chain columns are `byte_array`, so encoding to
1144
- * text would add ~33% to what are the largest columns in the schema.
1145
- *
1146
- * Key agreement, per message:
1147
- * shared_x = ECDH(ephemeral_privkey, org_pubkey).x // 32 bytes
1148
- * key = HKDF-SHA256(ikm=shared_x, salt=ephemeral_pubkey, info=domain, len=32)
1149
- * aad = "<domain>|<record_id>"
1150
- *
1151
- * A fresh ephemeral keypair is generated for every message and its private half is
1152
- * discarded immediately. This is what makes the scheme forward-secret with respect
1153
- * to the *sender*: leaking an agent's long-term signing key later does not expose
1154
- * anything it encrypted in the past. (Deriving the shared secret from the agent's
1155
- * static key instead would let anyone recompute every past shared secret, since the
1156
- * org's public key is public by definition.)
1157
- *
1158
- * Three separate bindings, each closing a different substitution:
1159
- * salt = ephemeral pubkey — ties the key to this exact handshake
1160
- * info = domain — a verdict payload cannot be read as a tool call
1161
- * aad = domain|record_id — a payload cannot be lifted onto another row
1078
+ * Build + sign a `log_encrypted_tool_call` transaction. Returns hex-encoded
1079
+ * signed tx, ready to POST as `signed_log_tool_call`.
1162
1080
  */
1081
+ declare function signEncryptedToolCall(toolCallId: string, action: string, context: string, toolName: string, toolArgsJson: string, orgEncryptionPubKey: string, privkeyHex: string, blockchainRidHex: string): string;
1082
+
1163
1083
  /**
1164
- * Cryptographic domain per payload kind. Fed to HKDF `info`, so each kind derives
1165
- * a different key from the same handshake — a verdict payload handed to the
1166
- * tool-call reader fails authentication rather than decoding to an empty struct.
1084
+ * Cryptographic domain per payload kind. Each kind derives a distinct
1085
+ * key from the same handshake — a verdict payload handed to the
1086
+ * tool-call reader fails authentication rather than silently decoding.
1167
1087
  *
1168
- * Must match `EciesDomain` in the dashboard's src/lib/chromia/ecies.ts exactly:
1169
- * the string is an input to key derivation, so any difference makes the two sides
1170
- * mutually unreadable.
1088
+ * Values here are the SHORT domain names the Rust core recognizes.
1089
+ * The full HKDF `info` strings (`atbash:chain-encryption:v1:<kind>`)
1090
+ * live inside the core and never surface at the API boundary.
1171
1091
  */
1172
1092
  declare const EciesDomain: {
1173
- readonly toolCall: "atbash:chain-encryption:v1:toolcall";
1174
- readonly verdict: "atbash:chain-encryption:v1:verdict";
1175
- readonly note: "atbash:chain-encryption:v1:note";
1176
- readonly policy: "atbash:chain-encryption:v1:policy";
1177
- readonly raw: "atbash:chain-encryption:v1:raw";
1093
+ readonly toolCall: "toolcall";
1094
+ readonly verdict: "verdict";
1095
+ readonly note: "note";
1096
+ readonly policy: "policy";
1097
+ readonly raw: "raw";
1178
1098
  };
1179
1099
  type EciesDomain = (typeof EciesDomain)[keyof typeof EciesDomain];
1180
1100
  /**
@@ -1189,9 +1109,9 @@ declare function encryptForOrg(plaintext: string, orgPubKeyHex: string, aad: str
1189
1109
  /**
1190
1110
  * Decrypt a payload produced by {@link encryptForOrg}.
1191
1111
  *
1192
- * Throws if the key is wrong, the `aad` does not match the one used at encrypt
1193
- * time, or the ciphertext was tampered with — GCM authentication makes all three
1194
- * indistinguishable by design.
1112
+ * Throws if the key is wrong, the `aad` does not match the one used at
1113
+ * encrypt time, or the ciphertext was tampered with — GCM authentication
1114
+ * makes all three indistinguishable by design.
1195
1115
  *
1196
1116
  * @param payload Value read from the on-chain `byte_array` column.
1197
1117
  * @param orgPrivKeyHex Org's secp256k1 private key (32 bytes hex).
@@ -1199,9 +1119,10 @@ declare function encryptForOrg(plaintext: string, orgPubKeyHex: string, aad: str
1199
1119
  */
1200
1120
  declare function decryptForOrg(payload: Uint8Array, orgPrivKeyHex: string, aad: string, domain?: EciesDomain): string;
1201
1121
  /**
1202
- * Size in bytes of the encrypted payload for a given plaintext length. Lets
1203
- * callers check against the on-chain column cap (MAX_CONTENT_CIPHER_SIZE)
1204
- * before submitting a transaction the contract would reject.
1122
+ * Size in bytes of the encrypted payload for a given plaintext length.
1123
+ * Lets callers check against the on-chain column cap
1124
+ * (`MAX_CONTENT_CIPHER_SIZE`) before submitting a transaction the
1125
+ * contract would reject.
1205
1126
  */
1206
1127
  declare function encryptedLength(plaintextByteLength: number): number;
1207
1128
 
@@ -1220,4 +1141,4 @@ declare function containsSecret(text: string): boolean;
1220
1141
  declare function createMemorySnapshot(entries: MemoryEntry[], takenAt: number): MemorySnapshot;
1221
1142
  declare function diffMemorySnapshots(before: MemorySnapshot, after: MemorySnapshot): MemoryDiffResult;
1222
1143
 
1223
- export { type ActionType, type AgentAuth, type AgentMemoryEntry, type AgentPolicy, type AnomalySeverity, type AnomalyType, Atbash, AtbashAPIError, type AtbashLogger, type AtbashOptions, type AtbashUserConfig, 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 FromConfigOptions, type GuardLogger, type GuardMemoryDecision, type GuardMemoryWriteInput, type GuardMemoryWriteResult, type HeldAction, type HeldActionReview, type HookDecision, type JudgeEndpointConfig, type JudgeOptions, type JudgeResult, type JudgmentState, type JudgmentStatus, 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, 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 ToolCallPlaintext, type ToolCallRecord, type ValidatedEndpoint, type Verdict, type WrappedLogger, classifyMemoryRead, classifyMemoryWrite, commitMemoryVersion, containsEvasionCharacters, containsSecret, createFileLogger, createMemoryGuardManager, createMemorySnapshot, decryptForOrg, decryptMemoryContent, defaultPluginLogPath, defaultPointerPath, deriveMemoryKey, derivePublicKey, diffMemorySnapshots, encryptForOrg, encryptMemoryContent, encryptedLength, flushTelemetry, generateKeypair, getActiveMemory, getActiveMemoryId, getAllAgentMemory, getConfigDir, getConfigPath, getMemoryById, getMemoryHistory, getRollbackHistory, guardMemoryWrite, isValidPrivateKey, loadAgent, loadAgentFromFile, loadUserConfig, normalizeActionForHash, normalizeForMatching, normalizeStatus, normalizeVerdict, pubkeyToHex, recordCall, recordDuration, redactJsonStrings, redactSecrets, resolve, resolveKeyPath, rollbackMemory, saveUserConfig, scanMemory, scanMemoryBatch, setupTelemetry, shutdownTelemetry, signEncryptedToolCall, signJudgeAction, signLogToolCall, syncLocalMemory, validateJudgeEndpoint, verifyJudgeResponseSignature, verifySignature };
1144
+ export { type ActionType, type AgentAuth, type AgentMemoryEntry, type AgentPolicy, type AnomalySeverity, type AnomalyType, Atbash, AtbashAPIError, type AtbashLogger, type AtbashOptions, type AtbashUserConfig, 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 FromConfigOptions, type GuardLogger, type GuardMemoryDecision, type GuardMemoryWriteInput, type GuardMemoryWriteResult, type HeldAction, type HeldActionReview, type HookDecision, type JudgeEndpointConfig, type JudgeOptions, type JudgeResult, type JudgmentState, type JudgmentStatus, 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, 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 ToolCallPlaintext, type ToolCallRecord, type ValidatedEndpoint, type Verdict, type WrappedLogger, claimHashHex, classifyMemoryRead, classifyMemoryWrite, commitMemoryVersion, containsEvasionCharacters, containsSecret, createFileLogger, createMemoryGuardManager, createMemorySnapshot, decryptForOrg, decryptMemoryContent, defaultPluginLogPath, defaultPointerPath, deriveMemoryKey, derivePublicKey, diffMemorySnapshots, encryptForOrg, encryptMemoryContent, encryptedLength, flushTelemetry, generateKeypair, getActiveMemory, getActiveMemoryId, getAllAgentMemory, getConfigDir, getConfigPath, getMemoryById, getMemoryHistory, getRollbackHistory, guardMemoryWrite, isValidPrivateKey, loadAgent, loadAgentFromFile, loadUserConfig, normalizeActionForHash, normalizeForMatching, normalizeStatus, normalizeVerdict, pubkeyToHex, recordCall, recordDuration, redactJsonStrings, redactSecrets, resolve, resolveKeyPath, rollbackMemory, saveUserConfig, scanMemory, scanMemoryBatch, setupTelemetry, shutdownTelemetry, signEncryptedToolCall, signJudgeAction, signLogToolCall, syncLocalMemory, validateJudgeEndpoint, verifyJudgeResponseSignature, verifySignature };