@atbash/sdk 0.7.0-dev.0 → 0.7.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/index.d.ts CHANGED
@@ -1,10 +1,75 @@
1
1
  /* auto-generated by NAPI-RS */
2
2
  /* eslint-disable */
3
+ export interface AddAgentMemoryArgsJs {
4
+ agent_pubkey: Buffer
5
+ content_cipher: Buffer
6
+ nonce: Buffer
7
+ score: number
8
+ }
9
+
10
+ export interface AgentAuthJs {
11
+ privkey: string
12
+ pubkey: string
13
+ }
14
+
15
+ export interface AgentPubkeyOnlyQueryJs {
16
+ agent_pubkey_hex: string
17
+ }
18
+
19
+ export const ARG_AGENT_PUBKEY: string
20
+
21
+ export const ARG_ID: string
22
+
23
+ export declare function buildAddAgentMemoryArgs(agentPubkeyHex: string, contentCipher: Buffer, nonce: Buffer, score: number): AddAgentMemoryArgsJs
24
+
25
+ export declare function buildEncryptedToolcallArgs(toolCallId: string, action: string, context: string, toolName: string, toolArgsJson: string, orgEncryptionPubKeyHex: string): EncryptedToolCallArgsJs
26
+
27
+ export declare function buildGetActiveMemoryIdQuery(agentPubkeyHex: string): AgentPubkeyOnlyQueryJs
28
+
29
+ export declare function buildGetAgentMemoryByIdQuery(agentPubkeyHex: string, id: number): MemoryByIdQueryJs
30
+
31
+ export declare function buildGetAgentMemoryHistoryQuery(agentPubkeyHex: string): AgentPubkeyOnlyQueryJs
32
+
33
+ export declare function buildGetAgentMemoryQuery(agentPubkeyHex: string): AgentPubkeyOnlyQueryJs
34
+
35
+ export declare function buildGetAgentMemoryRollbackHistoryQuery(agentPubkeyHex: string): AgentPubkeyOnlyQueryJs
36
+
37
+ export declare function buildGetAllAgentMemoryQuery(agentPubkeyHex: string): AgentPubkeyOnlyQueryJs
38
+
39
+ export declare function buildRollbackAgentMemoryArgs(agentPubkeyHex: string, toId: number, reason: string): RollbackAgentMemoryArgsJs
40
+
41
+ export declare function buildScanRequest(entry: MemoryEntryJs): ScanRequestJs
42
+
43
+ /**
44
+ * Named `claimHashHex` on the JS side to match the pure-TS name the
45
+ * dashboard's ported implementation uses.
46
+ */
47
+ export declare function claimHashHex(toolName: string, action: string, context: string, toolArgsJson: string): string
48
+
49
+ export declare function classifyMemoryRead(event: any, ctx: any, opts?: ClassifyReadOptionsJs | undefined | null): boolean
50
+
51
+ export declare function classifyMemoryWrite(event: any, ctx: any, opts?: ClassifyWriteOptionsJs | undefined | null): MemoryEntryJs | null
52
+
53
+ export interface ClassifyReadOptionsJs {
54
+ readToolNames?: Array<string>
55
+ patterns?: Array<string>
56
+ genericReadToolNames?: Array<string>
57
+ }
58
+
59
+ export interface ClassifyWriteOptionsJs {
60
+ patterns?: Array<string>
61
+ toolNames?: Array<string>
62
+ }
63
+
64
+ export declare function computeActionHash(action: string): string
65
+
3
66
  export declare function containsEvasionCharacters(s: string): boolean
4
67
 
5
68
  export declare function containsSecret(s: string): boolean
6
69
 
7
- export declare function createMemorySnapshot(entries: any, takenAt: number): any
70
+ export declare function createMemorySnapshot(entries: Array<MemoryEntryJs>, takenAt: number): MemorySnapshotJs
71
+
72
+ export declare function decryptForOrg(payload: Buffer, orgPrivKeyHex: string, aad: string, domain?: string | undefined | null): string
8
73
 
9
74
  export declare function decryptMemoryContent(ciphertext: Buffer, nonce: Buffer, key: Buffer): string
10
75
 
@@ -16,40 +81,210 @@ export const DEFAULT_PRIVATE_BLOCKCHAIN_RID: string
16
81
 
17
82
  export declare function defaultChromiaNodeUrls(): Array<string>
18
83
 
84
+ export declare function defaultMemoryPathPatterns(): Array<string>
85
+
86
+ export declare function defaultMemoryReadToolNames(): Array<string>
87
+
88
+ export declare function defaultMemoryWriteToolNames(): Array<string>
89
+
19
90
  export declare function defaultPrivateNodeUrls(): Array<string>
20
91
 
92
+ export declare function defaultScoreForVerdict(verdict: string): number
93
+
21
94
  export declare function deriveMemoryKey(privkeyHex: string): Buffer
22
95
 
23
96
  export declare function derivePublicKey(s: string): string
24
97
 
25
- export declare function diffMemorySnapshots(before: any, after: any): any
98
+ export declare function diffMemorySnapshots(before: MemorySnapshotJs, after: MemorySnapshotJs): MemoryDiffResultJs
99
+
100
+ export const ECIES_FORMAT_VERSION: number
101
+
102
+ export declare function encryptedLength(plaintextByteLength: number): number
26
103
 
27
- /**
28
- * Encrypt UTF-8 plaintext with a 32-byte AES key. Returns
29
- * `{ ciphertext: Buffer, nonce: Buffer }` — ciphertext has the GCM
30
- * auth tag appended as the trailing 16 bytes.
31
- */
32
104
  export interface EncryptedMemoryJs {
33
105
  ciphertext: Buffer
34
106
  nonce: Buffer
35
107
  }
36
108
 
109
+ /** Columns of `log_tool_call` — `tool_name` stays readable for filtering. */
110
+ export interface EncryptedToolCallArgsJs {
111
+ tool_call_id: string
112
+ action_text: string
113
+ action_context: string
114
+ tool_name: string
115
+ tool_args_json: string
116
+ }
117
+
118
+ export declare function encryptForOrg(plaintext: string, orgPubKeyHex: string, aad: string, domain?: string | undefined | null): Buffer
119
+
37
120
  export declare function encryptMemoryContent(plaintext: string, key: Buffer): EncryptedMemoryJs
38
121
 
39
- export declare function generateKeypair(): any
122
+ export declare function formatEntryForScan(entry: MemoryEntryJs, hasEvasion: boolean): string
123
+
124
+ export declare function generateKeypair(): KeyPairJs
40
125
 
41
126
  export const HONEYCOMB_KEY: string
42
127
 
43
128
  export declare function isValidPrivateKey(s: string): boolean
44
129
 
45
- export declare function loadAgent(privkey: string): any
130
+ export interface JudgeSignatureCheckJs {
131
+ ok: boolean
132
+ reason?: string
133
+ }
134
+
135
+ export interface KeyPairJs {
136
+ priv_key: string
137
+ pub_key: string
138
+ }
139
+
140
+ export declare function loadAgent(privkey: string): AgentAuthJs
141
+
142
+ export declare function mapVerdict(actionType: string, confidence: number, threshold: number): string
143
+
144
+ export interface MemoryAnomalyJs {
145
+ /**
146
+ * Anomaly kind — see `AnomalyType` in the core. Emitted as `type` in JS
147
+ * to match the serde `#[serde(rename = "type")]` on the core struct.
148
+ */
149
+ type: string
150
+ severity: string
151
+ description: string
152
+ entries: Array<string>
153
+ }
154
+
155
+ export interface MemoryByIdQueryJs {
156
+ agent_pubkey_hex: string
157
+ id: number
158
+ }
159
+
160
+ export interface MemoryDiffResultJs {
161
+ safe: boolean
162
+ added: Array<MemoryEntryJs>
163
+ removed: Array<MemoryEntryJs>
164
+ modified: Array<ModifiedEntryJs>
165
+ anomalies: Array<MemoryAnomalyJs>
166
+ }
167
+
168
+ export interface MemoryEntryJs {
169
+ key: string
170
+ value: string
171
+ source?: string
172
+ timestamp?: number
173
+ }
174
+
175
+ export declare function memoryScanContext(): string
176
+
177
+ export interface MemorySnapshotJs {
178
+ entries: Array<MemoryEntryJs>
179
+ takenAt: number
180
+ }
181
+
182
+ export interface ModifiedEntryJs {
183
+ key: string
184
+ before: string
185
+ after: string
186
+ }
187
+
188
+ export declare function normalizeActionForHash(action: string): string
46
189
 
47
190
  export declare function normalizeForMatching(s: string): string
48
191
 
49
- export declare function redactSecrets(s: string): any
192
+ export const OP_ADD_AGENT_MEMORY: string
193
+
194
+ export const OP_LOG_TOOL_CALL: string
195
+
196
+ export const OP_ROLLBACK_AGENT_MEMORY: string
197
+
198
+ export declare function parseActiveMemoryId(value: any): number | null
199
+
200
+ export declare function parseByteArrayField(value: any): Buffer
201
+
202
+ export interface ParsedScoreJs {
203
+ score?: number
204
+ clean_reason: string
205
+ }
206
+
207
+ export declare function parseMemoryRow(value: any): RawMemoryRowJs
208
+
209
+ export declare function parseMemoryRows(value: any): Array<RawMemoryRowJs>
210
+
211
+ export declare function parseRollbackRow(value: any): RawRollbackRowJs
212
+
213
+ export declare function parseRollbackRows(value: any): Array<RawRollbackRowJs>
214
+
215
+ export declare function parseScoreFromReason(reason: string): ParsedScoreJs
216
+
217
+ export const QUERY_GET_ACTIVE_MEMORY_ID: string
218
+
219
+ export const QUERY_GET_AGENT_MEMORY: string
220
+
221
+ export const QUERY_GET_AGENT_MEMORY_BY_ID: string
222
+
223
+ export const QUERY_GET_AGENT_MEMORY_HISTORY: string
224
+
225
+ export const QUERY_GET_AGENT_MEMORY_ROLLBACK_HISTORY: string
226
+
227
+ export const QUERY_GET_ALL_AGENT_MEMORY: string
228
+
229
+ export interface RawMemoryRowJs {
230
+ id: number
231
+ content_cipher: Buffer
232
+ nonce: Buffer
233
+ score: number
234
+ is_active: boolean
235
+ created_at: number
236
+ updated_at: number
237
+ }
238
+
239
+ export interface RawRollbackRowJs {
240
+ from_id: number
241
+ to_id: number
242
+ reason: string
243
+ signer: Buffer
244
+ created_at: number
245
+ }
246
+
247
+ export interface RedactResultJs {
248
+ redacted: string
249
+ found: Array<SecretMatchJs>
250
+ }
251
+
252
+ export declare function redactSecrets(s: string): RedactResultJs
253
+
254
+ export interface RollbackAgentMemoryArgsJs {
255
+ agent_pubkey: Buffer
256
+ to_id: number
257
+ reason: string
258
+ }
259
+
260
+ export interface ScanRequestJs {
261
+ prompt: string
262
+ context: string
263
+ redaction: RedactResultJs
264
+ has_evasion: boolean
265
+ }
266
+
267
+ export interface SecretMatchJs {
268
+ kind: string
269
+ length: number
270
+ }
271
+
272
+ export declare function signEncryptedToolCall(toolCallId: string, action: string, context: string, toolName: string, toolArgsJson: string, orgEncryptionPubKeyHex: string, privkeyHex: string, blockchainRidHex: string): string
50
273
 
51
274
  export declare function signJudgeAction(judgmentId: string, action: string, context: string, extra: string, privkey: string, blockchainRid: string): string
52
275
 
53
276
  export declare function signLogToolCall(toolCallId: string, action: string, context: string, toolName: string, toolArgsJson: string, privkey: string, blockchainRid: string): string
54
277
 
278
+ export declare function validateAgentPubkeyHex(pubkeyHex: string): Buffer
279
+
280
+ export declare function validateMemoryId(id: number): void
281
+
282
+ export declare function validateMemoryNonce(nonce: Buffer): void
283
+
284
+ export declare function validateRollbackReason(reason: string): void
285
+
286
+ export declare function validateScore(score: number): void
287
+
288
+ export declare function verifyJudgeResponseSignature(body: Buffer, signatureHex: string | undefined | null, pubkeyHex: string): JudgeSignatureCheckJs
289
+
55
290
  export declare function verifySignature(body: Buffer, signatureHex: string, pubkeyHex: string): boolean