@verax-ai/proxy 0.9.0 → 0.10.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/approvals.js CHANGED
@@ -369,6 +369,8 @@ async function approvePendingUnlocked(opts) {
369
369
  inputs: prior?.inputs ?? [],
370
370
  approver: approverInputs(opts),
371
371
  ...(signed.inputs?.dataClasses !== undefined ? { dataClasses: signed.inputs.dataClasses } : {}),
372
+ ...(prior?.session !== undefined ? { session: prior.session } : {}),
373
+ ...(prior?.toolLabels !== undefined ? { toolLabels: prior.toolLabels } : {}),
372
374
  };
373
375
  const inputsHash = sha256Canonical(inputs);
374
376
  const dispatchArgs = approvalDispatchArgs(snap);
@@ -0,0 +1,118 @@
1
+ /**
2
+ * A canary is a credential-shaped value nothing legitimate uses. The gate
3
+ * compares a call with the active values before the tool runs. The files and
4
+ * the decision name the id, never the value.
5
+ *
6
+ * `CANARY_CHECK_BOUND_MS` is the ceiling `canary-perf` enforces for one check
7
+ * of 50 canaries against about 4 KiB of punctuated prose and URLs. The
8
+ * measured median lives in `docs/PERF.md`.
9
+ */
10
+ export declare const CANARY_FILE = "canaries.json";
11
+ /** Exclusive create, same idea as `ledger.lock`. Held only across one add or remove. */
12
+ export declare const CANARY_LOCK_FILE = "canaries.lock";
13
+ export declare const CANARY_FINDING = "canary-exfiltration";
14
+ /**
15
+ * A local finding, not a signed alarm. `verax.incident.v1` is the memory
16
+ * integrity record: the incident writer accepts only those codes, signs them
17
+ * with the record key, and copies them to the alarm outbox. This file is
18
+ * written by the proxy, which does not hold that key, including when policy
19
+ * is `deny` and nothing halts. No alarm is sent.
20
+ */
21
+ export declare const CANARY_INCIDENT_PURPOSE = "verax.canary-finding.v1";
22
+ export declare const CANARY_CHECK_BOUND_MS = 25;
23
+ export declare const CANARY_SHAPES: readonly ["api-key", "bearer", "password", "card"];
24
+ export type CanaryShape = (typeof CANARY_SHAPES)[number];
25
+ export type StoredCanary = {
26
+ id: string;
27
+ label: string;
28
+ shape: CanaryShape;
29
+ value: string;
30
+ createdAt: string;
31
+ retiredAt: string | null;
32
+ };
33
+ export type CanaryListRow = {
34
+ id: string;
35
+ label: string;
36
+ createdAt: string;
37
+ status: "active" | "retired";
38
+ };
39
+ export type CanaryNeedle = {
40
+ id: string;
41
+ value: string;
42
+ };
43
+ export type CanaryMatch = {
44
+ id: string;
45
+ where: string;
46
+ subject: string;
47
+ };
48
+ export declare class CanaryStoreError extends Error {
49
+ constructor(message: string);
50
+ }
51
+ export declare function readCanaryFile(stateDir: string): StoredCanary[];
52
+ export declare function writeCanaryFile(stateDir: string, rows: readonly StoredCanary[]): void;
53
+ /**
54
+ * Runs after the store is read and before it is written, while the
55
+ * cross-process lock is held. The race test pauses one update on the
56
+ * snapshot it already read. Production leaves this null.
57
+ */
58
+ export declare const canaryTestHooks: {
59
+ afterRead: (() => void) | null;
60
+ };
61
+ export declare function addCanary(stateDir: string, opts?: {
62
+ label?: string;
63
+ shape?: CanaryShape;
64
+ now?: number;
65
+ }): {
66
+ id: string;
67
+ value: string;
68
+ label: string;
69
+ shape: CanaryShape;
70
+ createdAt: string;
71
+ };
72
+ /** `retired` when this call retired it or it was already retired. `missing` when the id is unknown. */
73
+ export declare function retireCanary(stateDir: string, id: string, now?: number): "retired" | "missing";
74
+ export declare function listCanaries(stateDir: string): CanaryListRow[];
75
+ /** The active value, for the operator plant path. A retired id returns null. */
76
+ export declare function activeCanaryValue(stateDir: string, id: string): string | null;
77
+ export declare function loadActiveCanaries(stateDir: string): {
78
+ ok: true;
79
+ canaries: CanaryNeedle[];
80
+ } | {
81
+ ok: false;
82
+ reason: "canary-unreadable";
83
+ };
84
+ /**
85
+ * The first active canary found in the arguments, the tool name, or the
86
+ * arguments joined so a value split across fields is still one string.
87
+ * String leaves are joined on their own, so a number sitting between two
88
+ * halves is not part of that string. A second join runs only when a number
89
+ * leaf is present, and it includes those leaves with the strings. A secret
90
+ * split into two JSON numbers is still one string when no string value sits
91
+ * between them. The string join is searched first. Hex is the whole value
92
+ * in any letter case. Base64 and base64url are searched at each byte
93
+ * alignment; an aligned slice is only a candidate until that slice and
94
+ * the bytes beside it decode to the whole value. A one-character near
95
+ * miss is not that value. Both are searched in the text and in each
96
+ * percent-decoded variant, including that variant with whitespace
97
+ * removed. Percent-encoding is decoded up to three times; an invalid `%`
98
+ * sequence is left as it is, and `+` is also tried as a space. A number
99
+ * leaf is read as `String(value)`. Past 32 levels or 1,000,000 characters
100
+ * the walk continues, iteratively, for the raw search only. A value that
101
+ * is found is a match. Otherwise the result is `too-wide`. The result
102
+ * never carries the value.
103
+ */
104
+ export declare function matchCanary(args: Record<string, unknown>, canaries: readonly CanaryNeedle[], toolName?: string): CanaryMatch | "too-wide" | null;
105
+ export declare function writeCanaryIncident(stateDir: string, hit: {
106
+ id: string;
107
+ where: string;
108
+ enforcement: "halt" | "deny";
109
+ observedAt: number;
110
+ }): void;
111
+ /**
112
+ * The same switch `verax halt` writes: an empty `halted` file, then one
113
+ * history line. A later call copies that line into the ledger. The line names
114
+ * the actor and does not name the value.
115
+ */
116
+ export declare function haltForCanary(stateDir: string, atMs: number): void;
117
+ /** Used when the switch file could not be written. Same flag the proxy already honours. */
118
+ export declare function markCanaryHalted(stateDir: string): void;