@atbash/sdk 0.7.1-dev.0 → 0.7.1
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/browser.d.mts +261 -39
- package/dist/browser.mjs +1351 -545
- package/dist/browser.mjs.map +1 -1
- package/dist/index.d.mts +261 -39
- package/dist/index.d.ts +261 -39
- package/dist/index.js +465 -327
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +449 -331
- package/dist/index.mjs.map +1 -1
- package/index.d.ts +245 -10
- package/index.js +243 -79
- package/package.json +7 -5
package/dist/browser.d.mts
CHANGED
|
@@ -11,6 +11,23 @@ interface ValidatedEndpoint {
|
|
|
11
11
|
policy: "default" | "self-hosted";
|
|
12
12
|
verifyPubKey: string | null;
|
|
13
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* Builds the trusted judge host set.
|
|
16
|
+
*
|
|
17
|
+
* The compiled-in default is always trusted: a `prod` build resolves it to
|
|
18
|
+
* atbash.ai, a dev build to whatever DEV_ENDPOINT was set at build time. No
|
|
19
|
+
* dev host is spelled out in source, and dev builds still validate their own
|
|
20
|
+
* default.
|
|
21
|
+
*
|
|
22
|
+
* Exported for tests only. The set is a build-time value and is deliberately
|
|
23
|
+
* never read from the process environment — an env var would let anyone widen
|
|
24
|
+
* the allowlist of an already-shipped artifact, which is the silent-redirection
|
|
25
|
+
* attack the allowlist exists to prevent (F-003). Asserting that requires
|
|
26
|
+
* calling this with the environment set, so it cannot stay module-private.
|
|
27
|
+
*
|
|
28
|
+
* @internal
|
|
29
|
+
*/
|
|
30
|
+
declare function buildAllowedJudgeHosts(): ReadonlySet<string>;
|
|
14
31
|
declare function validateJudgeEndpoint(judge?: JudgeEndpointConfig): ValidatedEndpoint;
|
|
15
32
|
|
|
16
33
|
/**
|
|
@@ -160,6 +177,13 @@ interface JudgeResult {
|
|
|
160
177
|
enforced: boolean;
|
|
161
178
|
/** Server-reported protection mode: `off`, `monitor`, or `enforce`. */
|
|
162
179
|
enforcementMode: string;
|
|
180
|
+
/**
|
|
181
|
+
* Server-reported response status. The judge sets `"logged"` on the AUDIT
|
|
182
|
+
* tier, where it deliberately returns no verdict. This is the ONLY signal
|
|
183
|
+
* that distinguishes "the server chose not to enforce" from "the verdict is
|
|
184
|
+
* missing" — never infer the former from a null verdict alone.
|
|
185
|
+
*/
|
|
186
|
+
status: string;
|
|
163
187
|
}
|
|
164
188
|
interface JudgmentStatus {
|
|
165
189
|
status: JudgmentState;
|
|
@@ -274,8 +298,24 @@ interface AtbashOptions {
|
|
|
274
298
|
* per-call `verifyPubKey` still overrides it.
|
|
275
299
|
*/
|
|
276
300
|
verifyPubKey?: string;
|
|
301
|
+
/**
|
|
302
|
+
* Org's encryption public key (33-byte compressed secp256k1, hex). When set,
|
|
303
|
+
* tool calls are sealed to it and signed as `log_encrypted_tool_call` instead
|
|
304
|
+
* of `log_tool_call`, so the action never reaches the block in clear.
|
|
305
|
+
*
|
|
306
|
+
* Required for any org that has registered a key — the contract refuses
|
|
307
|
+
* plaintext for those. Omitted, behaviour is unchanged. A per-call
|
|
308
|
+
* `orgEncryptionPubKey` overrides this, same as `verifyPubKey`.
|
|
309
|
+
*/
|
|
310
|
+
orgEncryptionPubKey?: string;
|
|
277
311
|
/** When true (default), `auditToolCall` denies on any error. */
|
|
278
312
|
failClosed?: boolean;
|
|
313
|
+
/**
|
|
314
|
+
* Verbose diagnostics. Off by default. When on, a failed judge call also
|
|
315
|
+
* logs the response body, which is the difference between "judge API failed"
|
|
316
|
+
* and knowing why it failed. Opt-in because that body can echo the action.
|
|
317
|
+
*/
|
|
318
|
+
debug?: boolean;
|
|
279
319
|
logger?: AtbashLogger;
|
|
280
320
|
}
|
|
281
321
|
/** Canonical decision returned by `auditToolCall`. */
|
|
@@ -316,6 +356,8 @@ interface FromConfigOptions {
|
|
|
316
356
|
/** Default org name — see {@link AtbashOptions.orgName}. */
|
|
317
357
|
orgName?: string;
|
|
318
358
|
failClosed?: boolean;
|
|
359
|
+
/** See {@link AtbashOptions.debug}. */
|
|
360
|
+
debug?: boolean;
|
|
319
361
|
logger?: AtbashLogger;
|
|
320
362
|
}
|
|
321
363
|
/** Options accepted by `judgeAction`. */
|
|
@@ -325,6 +367,8 @@ interface JudgeOptions {
|
|
|
325
367
|
provider?: string;
|
|
326
368
|
model?: string;
|
|
327
369
|
verifyPubKey?: string;
|
|
370
|
+
/** Per-call override of {@link AtbashOptions.orgEncryptionPubKey}. */
|
|
371
|
+
orgEncryptionPubKey?: string;
|
|
328
372
|
/**
|
|
329
373
|
* Org name — when set, the SDK resolves which chain the agent lives
|
|
330
374
|
* on via the off-chain `org_networks` map (authoritative) before
|
|
@@ -353,6 +397,8 @@ interface LogToolCallOptions {
|
|
|
353
397
|
toolArgsJson?: string;
|
|
354
398
|
/** Per-call chain override — same semantics as `JudgeOptions.chainOpts`. */
|
|
355
399
|
chainOpts?: ChainOpts;
|
|
400
|
+
/** Per-call override of {@link AtbashOptions.orgEncryptionPubKey}. */
|
|
401
|
+
orgEncryptionPubKey?: string;
|
|
356
402
|
}
|
|
357
403
|
|
|
358
404
|
interface ChainConfig {
|
|
@@ -370,8 +416,13 @@ declare class Atbash {
|
|
|
370
416
|
readonly orgName?: string;
|
|
371
417
|
/** Default judge response-signing pubkey, if configured (see fromConfig). */
|
|
372
418
|
readonly verifyPubKey?: string;
|
|
419
|
+
/** Default org encryption key — see {@link AtbashOptions.orgEncryptionPubKey}. */
|
|
420
|
+
readonly orgEncryptionPubKey?: string;
|
|
373
421
|
/** When true (default), `auditToolCall` denies on any error. */
|
|
374
422
|
readonly failClosed: boolean;
|
|
423
|
+
/** Org key learned from the last agent-exists check, for this agent only. */
|
|
424
|
+
private _orgKeyFromChain;
|
|
425
|
+
private readonly debug;
|
|
375
426
|
private readonly logger;
|
|
376
427
|
private readonly http;
|
|
377
428
|
/**
|
|
@@ -385,7 +436,20 @@ declare class Atbash {
|
|
|
385
436
|
* server-side replay protection windows never expire it mid-session.
|
|
386
437
|
*/
|
|
387
438
|
private _authBearer;
|
|
439
|
+
/** Guards `logEnvironmentOnce` — hosts construct several clients. */
|
|
440
|
+
private static environmentLogged;
|
|
388
441
|
constructor(privkey: string, options?: AtbashOptions);
|
|
442
|
+
/**
|
|
443
|
+
* Say which environment this build talks to, once per process.
|
|
444
|
+
*
|
|
445
|
+
* The endpoint and both chain RIDs are compiled in, chosen by the npm tag,
|
|
446
|
+
* and no configuration repoints a released build. So installing the build
|
|
447
|
+
* for the wrong environment is invisible: the plugin loads, the hook fires,
|
|
448
|
+
* and every judge call fails because the agent does not exist on the chain
|
|
449
|
+
* this build targets. Organisation names are not unique across environments
|
|
450
|
+
* either, so an org resolving is not evidence the build is right.
|
|
451
|
+
*/
|
|
452
|
+
private logEnvironmentOnce;
|
|
389
453
|
/**
|
|
390
454
|
* Construct from resolved config: explicit overrides → env vars → the
|
|
391
455
|
* `~/.config/atbash/config.json` file (see userConfig.resolve). The private
|
|
@@ -428,6 +492,15 @@ declare class Atbash {
|
|
|
428
492
|
* explicitly false.
|
|
429
493
|
*/
|
|
430
494
|
auditToolCall(input: ToolCallInput): Promise<Decision>;
|
|
495
|
+
/**
|
|
496
|
+
* One exit for every judge failure.
|
|
497
|
+
*
|
|
498
|
+
* Status and reason go in the *message*, not only in the meta object: hosts
|
|
499
|
+
* print the message and drop the meta, which is why this read as a bare
|
|
500
|
+
* "judge API failed" while the judge was answering with a precise reason.
|
|
501
|
+
* The response body follows only under `debug`, since it can echo the action.
|
|
502
|
+
*/
|
|
503
|
+
private failJudge;
|
|
431
504
|
private fail;
|
|
432
505
|
getJudgmentStatus(judgmentId: string, agentPubkey?: string): Promise<JudgmentStatus>;
|
|
433
506
|
getToolCalls(maxCount: number): Promise<ToolCallRecord[]>;
|
|
@@ -503,7 +576,13 @@ declare class Atbash {
|
|
|
503
576
|
private raiseIfError;
|
|
504
577
|
/** Wrap a failed HTTP *response* (non-2xx / non-200) as an AtbashAPIError. */
|
|
505
578
|
private httpError;
|
|
506
|
-
/**
|
|
579
|
+
/**
|
|
580
|
+
* Wrap a transport failure (fetch threw, no response) as an AtbashAPIError.
|
|
581
|
+
*
|
|
582
|
+
* `HttpTransportError.kind` names the cause; the message is already
|
|
583
|
+
* human-readable. `debug` echoes the original exception so operators can
|
|
584
|
+
* cross-reference with node / undici logs when a class doesn't match.
|
|
585
|
+
*/
|
|
507
586
|
private transportError;
|
|
508
587
|
private json;
|
|
509
588
|
static generateKeypair(): KeyPair;
|
|
@@ -529,6 +608,43 @@ declare class SignatureVerificationError extends Error {
|
|
|
529
608
|
constructor(message: string);
|
|
530
609
|
}
|
|
531
610
|
|
|
611
|
+
/**
|
|
612
|
+
* Thin typed fetch wrapper.
|
|
613
|
+
*
|
|
614
|
+
* openapi-typescript emits types only (no runtime client), so this is the
|
|
615
|
+
* single hand-written transport — generic `get`/`post` over global `fetch`
|
|
616
|
+
* with a per-request timeout. The endpoint-specific request/response *shapes*
|
|
617
|
+
* are pulled from the generated `schema.ts` at the call sites in client.ts, so
|
|
618
|
+
* the wire contract still lives in spec/openapi.yaml. Methods return the raw
|
|
619
|
+
* `Response` so the caller can read the exact bytes the server signed before
|
|
620
|
+
* any decode (judge signature verification) — mirroring the Python surface's
|
|
621
|
+
* use of raw httpx (DECISIONS 2026-05-22).
|
|
622
|
+
*/
|
|
623
|
+
type QueryValue = string | number | boolean | undefined | null;
|
|
624
|
+
declare class HttpClient {
|
|
625
|
+
readonly baseUrl: string;
|
|
626
|
+
readonly timeoutMs: number;
|
|
627
|
+
constructor(baseUrl: string, timeoutMs: number);
|
|
628
|
+
buildUrl(path: string, query?: Record<string, QueryValue>): string;
|
|
629
|
+
get(path: string, query?: Record<string, QueryValue>, headers?: Record<string, string>): Promise<Response>;
|
|
630
|
+
post(path: string, body: unknown, headers?: Record<string, string>): Promise<Response>;
|
|
631
|
+
private fetch;
|
|
632
|
+
}
|
|
633
|
+
/**
|
|
634
|
+
* A transport failure the SDK can act on. Every real cause the platform surfaces
|
|
635
|
+
* lands as one of these — the message names the cause in plain language so a
|
|
636
|
+
* plugin can show it to a user without decoding httpx / fetch internals.
|
|
637
|
+
*
|
|
638
|
+
* `cause` preserves the original error for debug logging; consumers that want
|
|
639
|
+
* the raw exception (e.g. tests) read it there.
|
|
640
|
+
*/
|
|
641
|
+
declare class HttpTransportError extends Error {
|
|
642
|
+
readonly kind: "timeout" | "aborted" | "dns" | "connect_refused" | "connection_reset" | "unknown";
|
|
643
|
+
constructor(kind: HttpTransportError["kind"], message: string, options?: {
|
|
644
|
+
cause?: unknown;
|
|
645
|
+
});
|
|
646
|
+
}
|
|
647
|
+
|
|
532
648
|
/** Normalize wire shapes (verdict casing, status, pubkey) to canonical forms. */
|
|
533
649
|
|
|
534
650
|
declare function normalizeVerdict(raw: unknown): Verdict;
|
|
@@ -543,6 +659,8 @@ interface AtbashUserConfig {
|
|
|
543
659
|
blockchainRid?: string;
|
|
544
660
|
provider?: string;
|
|
545
661
|
providerModel?: string;
|
|
662
|
+
/** "1" / "true" turns on verbose diagnostics. See AtbashOptions.debug. */
|
|
663
|
+
debug?: string;
|
|
546
664
|
}
|
|
547
665
|
declare function getConfigDir(): string;
|
|
548
666
|
declare function getConfigPath(): string;
|
|
@@ -553,6 +671,26 @@ declare function resolve(key: keyof AtbashUserConfig, flagValue?: string): strin
|
|
|
553
671
|
declare function resolveKeyPath(input?: string): string;
|
|
554
672
|
declare function loadAgentFromFile(keyPath?: string): AgentAuth;
|
|
555
673
|
|
|
674
|
+
/**
|
|
675
|
+
* Accepted key filenames, in precedence order.
|
|
676
|
+
*
|
|
677
|
+
* `guard-client-key` stays first: it is the name every existing install
|
|
678
|
+
* already has, and changing which file wins would silently switch agent
|
|
679
|
+
* identity for anyone holding both. `atbash-client-key` is accepted because
|
|
680
|
+
* it is the name people actually create — the old one carries retired
|
|
681
|
+
* branding — and hitting ENOENT on a key you just wrote, from a plugin that
|
|
682
|
+
* still reports itself installed, is a miserable first run.
|
|
683
|
+
*/
|
|
684
|
+
declare const KEY_FILENAMES: readonly ["guard-client-key", "atbash-client-key"];
|
|
685
|
+
/** Every path checked when no explicit key path is given, in order. */
|
|
686
|
+
declare function keyPathCandidates(): string[];
|
|
687
|
+
/**
|
|
688
|
+
* Pick the key path: an explicit input wins untouched; otherwise the first
|
|
689
|
+
* accepted filename that exists, falling back to the preferred name so the
|
|
690
|
+
* error names something recognisable when nothing is there.
|
|
691
|
+
*/
|
|
692
|
+
declare function chooseKeyPath(input: string | undefined, exists: (p: string) => boolean): string;
|
|
693
|
+
|
|
556
694
|
/**
|
|
557
695
|
* Canonical secret kinds reported by the Rust core in `SecretMatch.kind`.
|
|
558
696
|
* Wire is permissive (modelled as a free string in {@link SecretMatch})
|
|
@@ -571,6 +709,26 @@ declare function verifyJudgeResponseSignature(bodyBytes: Uint8Array, signatureHe
|
|
|
571
709
|
reason?: string;
|
|
572
710
|
};
|
|
573
711
|
|
|
712
|
+
/**
|
|
713
|
+
* The boot memory-sync failure line.
|
|
714
|
+
*
|
|
715
|
+
* Split out of `guard-manager.ts` so it can be asserted without constructing a
|
|
716
|
+
* guard manager, which needs the native addon. The message is the whole point
|
|
717
|
+
* of AT-304: hosts print the message and drop the structured meta, so a cause
|
|
718
|
+
* that lives only in meta never reaches the operator.
|
|
719
|
+
*/
|
|
720
|
+
/** Advice, not a diagnosis — appended only when the cause is unhelpful. */
|
|
721
|
+
declare const BOOT_SYNC_HINT = "check the chain endpoint and orgName if the cause above does not explain it";
|
|
722
|
+
/**
|
|
723
|
+
* Lead with the real cause.
|
|
724
|
+
*
|
|
725
|
+
* The previous wording named the chain endpoint and orgName as the things to
|
|
726
|
+
* check, which sent operators to verify configuration that was already correct
|
|
727
|
+
* while the actual cause (a node answering `404 Can't find blockchain with
|
|
728
|
+
* blockchainRID: …` for a chain it does not host) stayed hidden.
|
|
729
|
+
*/
|
|
730
|
+
declare function bootSyncFailureLine(cause: unknown): string;
|
|
731
|
+
|
|
574
732
|
/** Derive the 32-byte AES key from an agent's secp256k1 privkey (hex). Deterministic — same privkey always yields the same key. */
|
|
575
733
|
declare function deriveMemoryKey(privkey: string): Promise<Buffer>;
|
|
576
734
|
/** Encrypt UTF-8 plaintext. `ciphertext` has the 16-byte GCM auth tag appended, matching the SDK's on-chain byte layout. */
|
|
@@ -585,8 +743,8 @@ declare function decryptMemoryContent(ciphertext: Buffer, nonce: Buffer, key: Bu
|
|
|
585
743
|
* Scan a single memory entry for poisoning.
|
|
586
744
|
*
|
|
587
745
|
* `auth` is the agent that signs the on-chain audit log for the
|
|
588
|
-
* LLM-judge call.
|
|
589
|
-
*
|
|
746
|
+
* LLM-judge call. Unicode-evasion presence is surfaced to the prompt
|
|
747
|
+
* so the LLM can weight suspicion accordingly.
|
|
590
748
|
*/
|
|
591
749
|
declare function scanMemory(entry: MemoryEntry, auth: AgentAuth, opts?: MemoryScanOptions): Promise<MemoryScanResult>;
|
|
592
750
|
/**
|
|
@@ -617,9 +775,7 @@ interface RollbackMemoryOptions {
|
|
|
617
775
|
* deactivated on-chain.
|
|
618
776
|
*
|
|
619
777
|
* The caller is responsible for running `scanMemory` first when
|
|
620
|
-
* appropriate — this function does not gate on the verdict.
|
|
621
|
-
* `score` parameter is the only metadata that flows in alongside
|
|
622
|
-
* the ciphertext.
|
|
778
|
+
* appropriate — this function does not gate on the verdict.
|
|
623
779
|
*/
|
|
624
780
|
declare function commitMemoryVersion(plaintext: string, auth: AgentAuth, opts?: CommitMemoryOptions): Promise<void>;
|
|
625
781
|
/**
|
|
@@ -651,35 +807,28 @@ interface MemoryRollbackEvent {
|
|
|
651
807
|
* Cheap version-pointer probe. Returns just the id of the current
|
|
652
808
|
* active memory (or null if none). No ciphertext is transferred — the
|
|
653
809
|
* response is a single integer, so this is safe to call on every
|
|
654
|
-
* memory-read hot path.
|
|
655
|
-
* compare against a stored pointer and only refetch the full row via
|
|
656
|
-
* `getActiveMemory` when the id has changed.
|
|
810
|
+
* memory-read hot path.
|
|
657
811
|
*/
|
|
658
812
|
declare function getActiveMemoryId(auth: AgentAuth, chainOpts?: ChainOpts): Promise<number | null>;
|
|
659
813
|
/**
|
|
660
814
|
* Recent active memory entries — subset of active versions filtered
|
|
661
|
-
* by the chain's `MEMORY_RECENT_WINDOW_MS
|
|
662
|
-
*
|
|
663
|
-
* stale memory is worse than missing memory. For a time-unbounded
|
|
664
|
-
* view of every currently active version, use `getAllAgentMemory`.
|
|
815
|
+
* by the chain's `MEMORY_RECENT_WINDOW_MS`. For a time-unbounded view
|
|
816
|
+
* of every currently active version, use `getAllAgentMemory`.
|
|
665
817
|
*/
|
|
666
818
|
declare function getActiveMemory(auth: AgentAuth, chainOpts?: ChainOpts): Promise<AgentMemoryEntry[]>;
|
|
667
819
|
/**
|
|
668
820
|
* All currently-active memory entries with no time cutoff. Use this
|
|
669
|
-
* when you need every active version regardless of age
|
|
670
|
-
* dashboard listing, or a long-running agent whose oldest active
|
|
671
|
-
* versions may have fallen outside `getActiveMemory`'s recent window.
|
|
821
|
+
* when you need every active version regardless of age.
|
|
672
822
|
*/
|
|
673
823
|
declare function getAllAgentMemory(auth: AgentAuth, chainOpts?: ChainOpts): Promise<AgentMemoryEntry[]>;
|
|
674
824
|
/**
|
|
675
|
-
* Full version history — active + inactive, most recent first.
|
|
676
|
-
*
|
|
825
|
+
* Full version history — active + inactive, most recent first. Used
|
|
826
|
+
* by rollback UX to choose a target version.
|
|
677
827
|
*/
|
|
678
828
|
declare function getMemoryHistory(auth: AgentAuth, chainOpts?: ChainOpts): Promise<AgentMemoryEntry[]>;
|
|
679
829
|
/**
|
|
680
830
|
* Fetch a single memory entry by version id, including its current
|
|
681
|
-
* `is_active` state.
|
|
682
|
-
* before rolling back to it.
|
|
831
|
+
* `is_active` state.
|
|
683
832
|
*/
|
|
684
833
|
declare function getMemoryById(id: number, auth: AgentAuth, chainOpts?: ChainOpts): Promise<AgentMemoryEntry>;
|
|
685
834
|
/**
|
|
@@ -693,29 +842,15 @@ declare function getRollbackHistory(auth: AgentAuth, chainOpts?: ChainOpts): Pro
|
|
|
693
842
|
*/
|
|
694
843
|
declare function rollbackMemory(toId: number, reason: string, auth: AgentAuth, opts?: RollbackMemoryOptions): Promise<void>;
|
|
695
844
|
|
|
696
|
-
/**
|
|
697
|
-
* Classify a plugin tool-call event as a memory write.
|
|
698
|
-
*
|
|
699
|
-
* Plugins receive `before_tool_call` events from their host runtime
|
|
700
|
-
* (openclaw, Claude API, MCP, etc.) with varying argument shapes. This
|
|
701
|
-
* module normalizes across shapes and returns a `MemoryEntry` when the
|
|
702
|
-
* call is writing to a memory-like path, or `null` when the SDK should
|
|
703
|
-
* skip the memory-scan path entirely.
|
|
704
|
-
*
|
|
705
|
-
* `event` and `ctx` are typed `unknown` so any plugin can pass its
|
|
706
|
-
* native hook payloads without adaptation — the classifier probes
|
|
707
|
-
* common key names at runtime.
|
|
708
|
-
*/
|
|
709
|
-
|
|
710
845
|
/**
|
|
711
846
|
* Tool names that indicate a memory write. Lowercase — matched
|
|
712
|
-
* case-insensitively so
|
|
713
|
-
*
|
|
847
|
+
* case-insensitively so OpenClaw (lowercase) and Claude API family
|
|
848
|
+
* (TitleCase) both hit.
|
|
714
849
|
*/
|
|
715
850
|
declare const DEFAULT_MEMORY_WRITE_TOOL_NAMES: ReadonlyArray<string>;
|
|
716
851
|
/**
|
|
717
852
|
* File path substrings that indicate a memory-shaped target. Callers
|
|
718
|
-
*
|
|
853
|
+
* extend or override via `classifyMemoryWrite` options.
|
|
719
854
|
*/
|
|
720
855
|
declare const DEFAULT_MEMORY_PATH_PATTERNS: ReadonlyArray<string>;
|
|
721
856
|
/**
|
|
@@ -911,7 +1046,7 @@ declare function createFileLogger(filePath: string, upstream?: UpstreamLogger):
|
|
|
911
1046
|
/** Default log-file location — `<workspaceDir>/.atbash/plugin.log`. */
|
|
912
1047
|
declare function defaultPluginLogPath(workspaceDir?: string): string;
|
|
913
1048
|
|
|
914
|
-
/** Dedicated memory-read tool names, matched case-insensitively.
|
|
1049
|
+
/** Dedicated memory-read tool names, matched case-insensitively. */
|
|
915
1050
|
declare const DEFAULT_MEMORY_READ_TOOL_NAMES: ReadonlyArray<string>;
|
|
916
1051
|
interface ClassifyMemoryReadOptions {
|
|
917
1052
|
/** Tool names that always count as memory reads. Merged with defaults. */
|
|
@@ -925,6 +1060,10 @@ interface ClassifyMemoryReadOptions {
|
|
|
925
1060
|
* Returns `true` when this tool call is a memory read — either a
|
|
926
1061
|
* dedicated memory-read tool from `readToolNames`, or a generic read
|
|
927
1062
|
* tool (`read` / `read_file`) targeting a memory-shaped path.
|
|
1063
|
+
*
|
|
1064
|
+
* Caller-supplied `patterns` are MERGED with the defaults (matches
|
|
1065
|
+
* Node's original behavior — extending in one plugin doesn't disable
|
|
1066
|
+
* standard coverage).
|
|
928
1067
|
*/
|
|
929
1068
|
declare function classifyMemoryRead(event: unknown, ctx: unknown, opts?: ClassifyMemoryReadOptions): boolean;
|
|
930
1069
|
|
|
@@ -1044,11 +1183,94 @@ declare function flushTelemetry(): Promise<void>;
|
|
|
1044
1183
|
*/
|
|
1045
1184
|
declare function shutdownTelemetry(): Promise<void>;
|
|
1046
1185
|
|
|
1186
|
+
/**
|
|
1187
|
+
* Rust core does the work; `browser/encrypted-toolcall.ts` mirrors it for the
|
|
1188
|
+
* browser and must produce the same columns.
|
|
1189
|
+
*/
|
|
1190
|
+
/** Must match `column_aad` in the core — the label binds a ciphertext to its column. */
|
|
1191
|
+
declare function columnAad(toolCallId: string, column: string): string;
|
|
1192
|
+
/** Byte-identical to the dashboard's copy — diverging breaks hold-retry resolution. */
|
|
1193
|
+
declare function normalizeActionForHash(action: string): string;
|
|
1194
|
+
/** Lets the judge check the request body against the ciphertext without an org key. */
|
|
1195
|
+
declare function claimHashHex(toolName: string, action: string, context: string, toolArgsJson: string): string;
|
|
1196
|
+
/** @returns hex-encoded signed tx, ready to POST as `signed_log_tool_call`. */
|
|
1197
|
+
declare function signEncryptedToolCall(toolCallId: string, action: string, context: string, toolName: string, toolArgsJson: string, orgEncryptionPubKey: string, privkeyHex: string, blockchainRidHex: string): string;
|
|
1198
|
+
|
|
1199
|
+
/**
|
|
1200
|
+
* Cryptographic domain per payload kind. Each kind derives a distinct
|
|
1201
|
+
* key from the same handshake — a verdict payload handed to the
|
|
1202
|
+
* tool-call reader fails authentication rather than silently decoding.
|
|
1203
|
+
*
|
|
1204
|
+
* Values here are the SHORT domain names the Rust core recognizes.
|
|
1205
|
+
* The full HKDF `info` strings (`atbash:chain-encryption:v1:<kind>`)
|
|
1206
|
+
* live inside the core and never surface at the API boundary.
|
|
1207
|
+
*/
|
|
1208
|
+
declare const EciesDomain: {
|
|
1209
|
+
readonly toolCall: "toolcall";
|
|
1210
|
+
readonly verdict: "verdict";
|
|
1211
|
+
readonly note: "note";
|
|
1212
|
+
readonly policy: "policy";
|
|
1213
|
+
readonly raw: "raw";
|
|
1214
|
+
};
|
|
1215
|
+
type EciesDomain = (typeof EciesDomain)[keyof typeof EciesDomain];
|
|
1216
|
+
/**
|
|
1217
|
+
* Encrypt `plaintext` so that only the holder of `orgPubKeyHex` can read it.
|
|
1218
|
+
*
|
|
1219
|
+
* @param plaintext UTF-8 text to protect.
|
|
1220
|
+
* @param orgPubKeyHex Org's compressed secp256k1 public key (33 bytes hex).
|
|
1221
|
+
* @param aad Context bound to the ciphertext — pass the record's id.
|
|
1222
|
+
* @returns raw payload for a Rell `byte_array` column.
|
|
1223
|
+
*/
|
|
1224
|
+
declare function encryptForOrg(plaintext: string, orgPubKeyHex: string, aad: string, domain?: EciesDomain): Uint8Array;
|
|
1225
|
+
/**
|
|
1226
|
+
* Decrypt a payload produced by {@link encryptForOrg}.
|
|
1227
|
+
*
|
|
1228
|
+
* Throws if the key is wrong, the `aad` does not match the one used at
|
|
1229
|
+
* encrypt time, or the ciphertext was tampered with — GCM authentication
|
|
1230
|
+
* makes all three indistinguishable by design.
|
|
1231
|
+
*
|
|
1232
|
+
* @param payload Value read from the on-chain `byte_array` column.
|
|
1233
|
+
* @param orgPrivKeyHex Org's secp256k1 private key (32 bytes hex).
|
|
1234
|
+
* @param aad Must equal the `aad` used when encrypting.
|
|
1235
|
+
*/
|
|
1236
|
+
declare function decryptForOrg(payload: Uint8Array, orgPrivKeyHex: string, aad: string, domain?: EciesDomain): string;
|
|
1237
|
+
/**
|
|
1238
|
+
* Size in bytes of the encrypted payload for a given plaintext length.
|
|
1239
|
+
* Lets callers check against the on-chain column cap
|
|
1240
|
+
* (`MAX_CONTENT_CIPHER_SIZE`) before submitting a transaction the
|
|
1241
|
+
* contract would reject.
|
|
1242
|
+
*/
|
|
1243
|
+
declare function encryptedLength(plaintextByteLength: number): number;
|
|
1244
|
+
|
|
1245
|
+
/**
|
|
1246
|
+
* atb1.<key-fingerprint>.<claim-hash>.<base64 ciphertext>
|
|
1247
|
+
*
|
|
1248
|
+
* Normative spec: `core/src/crypto_envelope.rs`. This mirrors it for the browser.
|
|
1249
|
+
*/
|
|
1250
|
+
interface Envelope {
|
|
1251
|
+
/** First 8 bytes of the recipient public key, hex. May be empty. */
|
|
1252
|
+
keyFingerprint: string;
|
|
1253
|
+
/** Commitment to the accompanying plaintext claims. May be empty. */
|
|
1254
|
+
claimHash: string;
|
|
1255
|
+
/** Raw ECIES payload. */
|
|
1256
|
+
payload: Uint8Array;
|
|
1257
|
+
}
|
|
1258
|
+
declare function packEnvelope(payload: Uint8Array, keyFingerprint?: string, claimHash?: string): string;
|
|
1259
|
+
/**
|
|
1260
|
+
* Stays true for a truncated envelope that `parseEnvelope` rejects — a severed
|
|
1261
|
+
* ciphertext is not plaintext, so callers must show a placeholder.
|
|
1262
|
+
*/
|
|
1263
|
+
declare function isEnvelope(value: string): boolean;
|
|
1264
|
+
/** Null, not a throw — pre-encryption records are plaintext. */
|
|
1265
|
+
declare function parseEnvelope(value: string): Envelope | null;
|
|
1266
|
+
declare function keyFingerprintOf(pubKeyHex: string): string;
|
|
1267
|
+
|
|
1047
1268
|
declare function isValidPrivateKey(hex: string): boolean;
|
|
1048
1269
|
declare function derivePublicKey(privkey: string): string;
|
|
1049
1270
|
declare function generateKeypair(): KeyPair;
|
|
1050
1271
|
declare function loadAgent(privkey: string): AgentAuth;
|
|
1051
1272
|
declare function signLogToolCall(toolCallId: string, action: string, context: string, toolName: string, toolArgsJson: string, privkey: string, blockchainRid: string): string;
|
|
1273
|
+
|
|
1052
1274
|
declare function signJudgeAction(judgmentId: string, action: string, context: string, extra: string, privkey: string, blockchainRid: string): string;
|
|
1053
1275
|
declare function verifySignature(body: Buffer, signatureHex: string, pubkeyHex: string): boolean;
|
|
1054
1276
|
declare function normalizeForMatching(text: string): string;
|
|
@@ -1058,4 +1280,4 @@ declare function containsSecret(text: string): boolean;
|
|
|
1058
1280
|
declare function createMemorySnapshot(entries: MemoryEntry[], takenAt: number): MemorySnapshot;
|
|
1059
1281
|
declare function diffMemorySnapshots(before: MemorySnapshot, after: MemorySnapshot): MemoryDiffResult;
|
|
1060
1282
|
|
|
1061
|
-
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, 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 ToolCallRecord, type ValidatedEndpoint, type Verdict, type WrappedLogger, classifyMemoryRead, classifyMemoryWrite, commitMemoryVersion, containsEvasionCharacters, containsSecret, createFileLogger, createMemoryGuardManager, createMemorySnapshot, decryptMemoryContent, defaultPluginLogPath, defaultPointerPath, deriveMemoryKey, derivePublicKey, diffMemorySnapshots, encryptMemoryContent, flushTelemetry, generateKeypair, getActiveMemory, getActiveMemoryId, getAllAgentMemory, getConfigDir, getConfigPath, getMemoryById, getMemoryHistory, getRollbackHistory, guardMemoryWrite, isValidPrivateKey, loadAgent, loadAgentFromFile, loadUserConfig, normalizeForMatching, normalizeStatus, normalizeVerdict, pubkeyToHex, recordCall, recordDuration, redactJsonStrings, redactSecrets, resolve, resolveKeyPath, rollbackMemory, saveUserConfig, scanMemory, scanMemoryBatch, setupTelemetry, shutdownTelemetry, signJudgeAction, signLogToolCall, syncLocalMemory, validateJudgeEndpoint, verifyJudgeResponseSignature, verifySignature };
|
|
1283
|
+
export { type ActionType, type AgentAuth, type AgentMemoryEntry, type AgentPolicy, type AnomalySeverity, type AnomalyType, Atbash, AtbashAPIError, type AtbashLogger, type AtbashOptions, type AtbashUserConfig, BOOT_SYNC_HINT, 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, 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, chooseKeyPath, claimHashHex, classifyMemoryRead, classifyMemoryWrite, columnAad, 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, isEnvelope, isValidPrivateKey, keyFingerprintOf, keyPathCandidates, loadAgent, loadAgentFromFile, loadUserConfig, normalizeActionForHash, 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 };
|