sigild 0.0.13 → 0.0.14

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.
Files changed (107) hide show
  1. package/README.md +50 -3
  2. package/THREAT_MODEL.md +2 -0
  3. package/dist/src/audit/index.d.ts +1 -1
  4. package/dist/src/audit/index.d.ts.map +1 -1
  5. package/dist/src/audit/index.js.map +1 -1
  6. package/dist/src/audit/log.d.ts +15 -0
  7. package/dist/src/audit/log.d.ts.map +1 -1
  8. package/dist/src/audit/log.js +2 -0
  9. package/dist/src/audit/log.js.map +1 -1
  10. package/dist/src/bin/sigil-mcp.js +68 -7
  11. package/dist/src/bin/sigil-mcp.js.map +1 -1
  12. package/dist/src/cli/paths.d.ts +2 -0
  13. package/dist/src/cli/paths.d.ts.map +1 -1
  14. package/dist/src/cli/paths.js +1 -0
  15. package/dist/src/cli/paths.js.map +1 -1
  16. package/dist/src/confirm/config.d.ts +19 -0
  17. package/dist/src/confirm/config.d.ts.map +1 -1
  18. package/dist/src/confirm/config.js +48 -0
  19. package/dist/src/confirm/config.js.map +1 -1
  20. package/dist/src/confirm/index.d.ts +1 -1
  21. package/dist/src/confirm/index.d.ts.map +1 -1
  22. package/dist/src/confirm/index.js.map +1 -1
  23. package/dist/src/daemon/handles.d.ts +6 -0
  24. package/dist/src/daemon/handles.d.ts.map +1 -1
  25. package/dist/src/daemon/handles.js +11 -0
  26. package/dist/src/daemon/handles.js.map +1 -1
  27. package/dist/src/daemon/index.d.ts +1 -1
  28. package/dist/src/daemon/index.d.ts.map +1 -1
  29. package/dist/src/daemon/index.js.map +1 -1
  30. package/dist/src/daemon/methods.d.ts +21 -0
  31. package/dist/src/daemon/methods.d.ts.map +1 -1
  32. package/dist/src/daemon/methods.js +179 -27
  33. package/dist/src/daemon/methods.js.map +1 -1
  34. package/dist/src/eth/abi.d.ts +82 -0
  35. package/dist/src/eth/abi.d.ts.map +1 -0
  36. package/dist/src/eth/abi.js +328 -0
  37. package/dist/src/eth/abi.js.map +1 -0
  38. package/dist/src/eth/index.d.ts +1 -0
  39. package/dist/src/eth/index.d.ts.map +1 -1
  40. package/dist/src/eth/index.js +1 -0
  41. package/dist/src/eth/index.js.map +1 -1
  42. package/dist/src/mcp/parent-watchdog.d.ts +31 -0
  43. package/dist/src/mcp/parent-watchdog.d.ts.map +1 -0
  44. package/dist/src/mcp/parent-watchdog.js +35 -0
  45. package/dist/src/mcp/parent-watchdog.js.map +1 -0
  46. package/dist/src/mcp/server.d.ts +7 -0
  47. package/dist/src/mcp/server.d.ts.map +1 -1
  48. package/dist/src/mcp/server.js +13 -2
  49. package/dist/src/mcp/server.js.map +1 -1
  50. package/dist/src/mcp/tools.d.ts.map +1 -1
  51. package/dist/src/mcp/tools.js +21 -1
  52. package/dist/src/mcp/tools.js.map +1 -1
  53. package/dist/src/policy/ledger.d.ts +1 -0
  54. package/dist/src/policy/ledger.d.ts.map +1 -1
  55. package/dist/src/policy/ledger.js +70 -44
  56. package/dist/src/policy/ledger.js.map +1 -1
  57. package/dist/src/policy/loader.d.ts.map +1 -1
  58. package/dist/src/policy/loader.js +9 -0
  59. package/dist/src/policy/loader.js.map +1 -1
  60. package/dist/src/policy/template.d.ts +2 -2
  61. package/dist/src/policy/template.d.ts.map +1 -1
  62. package/dist/src/policy/template.js +20 -0
  63. package/dist/src/policy/template.js.map +1 -1
  64. package/dist/src/policy/types.d.ts +16 -0
  65. package/dist/src/policy/types.d.ts.map +1 -1
  66. package/dist/src/policy/types.js.map +1 -1
  67. package/dist/src/preview/abi-dir.d.ts +50 -0
  68. package/dist/src/preview/abi-dir.d.ts.map +1 -0
  69. package/dist/src/preview/abi-dir.js +175 -0
  70. package/dist/src/preview/abi-dir.js.map +1 -0
  71. package/dist/src/preview/decode.d.ts +26 -0
  72. package/dist/src/preview/decode.d.ts.map +1 -0
  73. package/dist/src/preview/decode.js +110 -0
  74. package/dist/src/preview/decode.js.map +1 -0
  75. package/dist/src/preview/format.d.ts +45 -0
  76. package/dist/src/preview/format.d.ts.map +1 -0
  77. package/dist/src/preview/format.js +222 -0
  78. package/dist/src/preview/format.js.map +1 -0
  79. package/dist/src/preview/index.d.ts +60 -0
  80. package/dist/src/preview/index.d.ts.map +1 -0
  81. package/dist/src/preview/index.js +163 -0
  82. package/dist/src/preview/index.js.map +1 -0
  83. package/dist/src/preview/known.d.ts +74 -0
  84. package/dist/src/preview/known.d.ts.map +1 -0
  85. package/dist/src/preview/known.js +425 -0
  86. package/dist/src/preview/known.js.map +1 -0
  87. package/dist/src/preview/simulate.d.ts +156 -0
  88. package/dist/src/preview/simulate.d.ts.map +1 -0
  89. package/dist/src/preview/simulate.js +768 -0
  90. package/dist/src/preview/simulate.js.map +1 -0
  91. package/dist/src/preview/simulators.d.ts +39 -0
  92. package/dist/src/preview/simulators.d.ts.map +1 -0
  93. package/dist/src/preview/simulators.js +71 -0
  94. package/dist/src/preview/simulators.js.map +1 -0
  95. package/dist/src/preview/trust.d.ts +49 -0
  96. package/dist/src/preview/trust.d.ts.map +1 -0
  97. package/dist/src/preview/trust.js +279 -0
  98. package/dist/src/preview/trust.js.map +1 -0
  99. package/dist/src/preview/types.d.ts +69 -0
  100. package/dist/src/preview/types.d.ts.map +1 -0
  101. package/dist/src/preview/types.js +11 -0
  102. package/dist/src/preview/types.js.map +1 -0
  103. package/dist/src/preview/units.d.ts +75 -0
  104. package/dist/src/preview/units.d.ts.map +1 -0
  105. package/dist/src/preview/units.js +228 -0
  106. package/dist/src/preview/units.js.map +1 -0
  107. package/package.json +1 -1
@@ -0,0 +1,75 @@
1
+ import type { TokenMetaLookup } from './types.js';
2
+ /**
3
+ * Small pure formatters shared by the decoder, the simulator and the preview
4
+ * renderer. Kept separate from format.ts so known.ts can use them without
5
+ * importing the renderer (and the renderer's simulation types).
6
+ */
7
+ export declare const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
8
+ export declare const MAX_UINT256: bigint;
9
+ /** At or above this, an allowance is "unlimited" for every practical purpose. */
10
+ export declare const UNLIMITED_THRESHOLD: bigint;
11
+ /** `0x1111…1111` — enough to eyeball against the address you expected. */
12
+ export declare function shortAddr(addr: string): string;
13
+ /** Longest hex quantity accepted from a node: uint256, 64 hex digits. */
14
+ export declare const MAX_QTY_HEX_DIGITS = 64;
15
+ /**
16
+ * Parse a JSON-RPC hex quantity from a node, or null if it is malformed or
17
+ * wider than uint256. Bounded regex, so the check itself is linear.
18
+ */
19
+ export declare function hexQuantity(v: unknown): bigint | null;
20
+ /** 1234567 → "1,234,567". Linear: built with a loop, no regex. */
21
+ export declare function groupThousands(n: bigint): string;
22
+ /**
23
+ * Exact fixed-point rendering with thousands separators and trailing zeros
24
+ * trimmed: (1000500000n, 6) → "1,000.5". Exact rather than rounded — a
25
+ * signing prompt is the wrong place to approximate.
26
+ */
27
+ export declare function formatUnits(amount: bigint, decimals: number): string;
28
+ export declare function formatEth(wei: bigint): string;
29
+ /** True when an allowance amount is the max of its type or ≥ 2^255. */
30
+ export declare function isUnlimited(amount: bigint, bits?: number): boolean;
31
+ /** The token's symbol if known, else its short address. */
32
+ export declare function tokenLabel(token: string, meta: TokenMetaLookup): string;
33
+ /**
34
+ * Amount for a call argument: `UNLIMITED` for allowance-style maxima (when
35
+ * `bits` is given), `1,000.5 USDC` when decimals are known, else the raw
36
+ * integer.
37
+ */
38
+ export declare function argAmount(amount: bigint, token: string | null, meta: TokenMetaLookup, opts?: {
39
+ allowanceBits?: number;
40
+ }): string;
41
+ /**
42
+ * Amount for a headline: always names the token. `1,000.5 USDC`,
43
+ * `UNLIMITED USDC`, or `5 of 0xa0b8…eb48` when decimals are unknown.
44
+ */
45
+ export declare function headAmount(amount: bigint, token: string, meta: TokenMetaLookup, opts?: {
46
+ allowanceBits?: number;
47
+ }): string;
48
+ /** Unix seconds → ISO-8601, or the raw number when out of a sane range. */
49
+ export declare function formatTimestamp(secs: bigint): string;
50
+ /** Bytes as 0x hex, truncated to 32 bytes with a length suffix. */
51
+ export declare function truncHex(hex: string): string;
52
+ /**
53
+ * Render an ABI-decoded value for display. `short` shortens addresses
54
+ * (call-line text); the structured args keep them in full.
55
+ */
56
+ export declare function renderValue(type: string, v: unknown, short?: boolean, depth?: number): string;
57
+ /** Split "a,(b,c),d[]" at top-level commas. */
58
+ export declare function splitTopLevel(s: string): string[];
59
+ /**
60
+ * Strip characters that could break or forge lines in what a human reads:
61
+ * C0/C1 controls (incl. \n, \r, \t), DEL, U+2028/2029 line/paragraph
62
+ * separators and the bidi overrides/isolates. Applied at the render
63
+ * boundary to every line of preview text, the headline and the warnings —
64
+ * defence in depth behind the per-source checks (identifier-only ABI names,
65
+ * quoted revert strings, allowlisted symbols).
66
+ */
67
+ export declare function clean(s: string): string;
68
+ /**
69
+ * Sanitize a token symbol read from a contract. The symbol is chosen by
70
+ * whoever deployed the token, and it lands on the user's phone and in the
71
+ * agent's context: allow a conservative printable set and a short length,
72
+ * or nothing (callers then fall back to the address).
73
+ */
74
+ export declare function sanitizeSymbol(s: string): string | undefined;
75
+ //# sourceMappingURL=units.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"units.d.ts","sourceRoot":"","sources":["../../../src/preview/units.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAa,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7D;;;;GAIG;AAEH,eAAO,MAAM,YAAY,+CAA+C,CAAC;AACzE,eAAO,MAAM,WAAW,QAAoB,CAAC;AAC7C,iFAAiF;AACjF,eAAO,MAAM,mBAAmB,QAAa,CAAC;AAE9C,0EAA0E;AAC1E,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAG9C;AAWD,yEAAyE;AACzE,eAAO,MAAM,kBAAkB,KAAK,CAAC;AAGrC;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAGrD;AAED,kEAAkE;AAClE,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAWhD;AAQD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AC,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAO5D"}
@@ -0,0 +1,228 @@
1
+ /**
2
+ * Small pure formatters shared by the decoder, the simulator and the preview
3
+ * renderer. Kept separate from format.ts so known.ts can use them without
4
+ * importing the renderer (and the renderer's simulation types).
5
+ */
6
+ export const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
7
+ export const MAX_UINT256 = (1n << 256n) - 1n;
8
+ /** At or above this, an allowance is "unlimited" for every practical purpose. */
9
+ export const UNLIMITED_THRESHOLD = 1n << 255n;
10
+ /** `0x1111…1111` — enough to eyeball against the address you expected. */
11
+ export function shortAddr(addr) {
12
+ const a = addr.toLowerCase();
13
+ return a.length === 42 ? `${a.slice(0, 6)}…${a.slice(-4)}` : a;
14
+ }
15
+ /**
16
+ * Anything at or above 10^80 is not a real amount (uint256 tops out at
17
+ * ~1.2e77). Formatting refuses it before calling BigInt.toString, whose
18
+ * cost grows super-linearly with the digit count — a node or contract
19
+ * must not be able to stall the event loop with a 100k-digit "gasUsed".
20
+ */
21
+ const FORMAT_CAP = 10n ** 80n;
22
+ const HUGE = '≥1e80 (not a real amount)';
23
+ /** Longest hex quantity accepted from a node: uint256, 64 hex digits. */
24
+ export const MAX_QTY_HEX_DIGITS = 64;
25
+ const QTY_RE = /^0x[0-9a-fA-F]{1,64}$/;
26
+ /**
27
+ * Parse a JSON-RPC hex quantity from a node, or null if it is malformed or
28
+ * wider than uint256. Bounded regex, so the check itself is linear.
29
+ */
30
+ export function hexQuantity(v) {
31
+ if (typeof v !== 'string' || !QTY_RE.test(v))
32
+ return null;
33
+ return BigInt(v);
34
+ }
35
+ /** 1234567 → "1,234,567". Linear: built with a loop, no regex. */
36
+ export function groupThousands(n) {
37
+ const neg = n < 0n;
38
+ const abs = neg ? -n : n;
39
+ if (abs >= FORMAT_CAP)
40
+ return (neg ? '-' : '') + HUGE;
41
+ const s = abs.toString();
42
+ let out = '';
43
+ for (let i = 0; i < s.length; i++) {
44
+ if (i > 0 && (s.length - i) % 3 === 0)
45
+ out += ',';
46
+ out += s[i];
47
+ }
48
+ return neg ? `-${out}` : out;
49
+ }
50
+ function trimTrailingZeros(s) {
51
+ let end = s.length;
52
+ while (end > 0 && s[end - 1] === '0')
53
+ end--;
54
+ return s.slice(0, end);
55
+ }
56
+ /**
57
+ * Exact fixed-point rendering with thousands separators and trailing zeros
58
+ * trimmed: (1000500000n, 6) → "1,000.5". Exact rather than rounded — a
59
+ * signing prompt is the wrong place to approximate.
60
+ */
61
+ export function formatUnits(amount, decimals) {
62
+ const neg = amount < 0n;
63
+ const abs = neg ? -amount : amount;
64
+ if (abs >= FORMAT_CAP)
65
+ return (neg ? '-' : '') + HUGE;
66
+ if (decimals === 0)
67
+ return (neg ? '-' : '') + groupThousands(abs);
68
+ const scale = 10n ** BigInt(decimals);
69
+ const whole = abs / scale;
70
+ const frac = trimTrailingZeros((abs % scale).toString().padStart(decimals, '0'));
71
+ return (neg ? '-' : '') + groupThousands(whole) + (frac === '' ? '' : `.${frac}`);
72
+ }
73
+ export function formatEth(wei) {
74
+ return `${formatUnits(wei, 18)} ETH`;
75
+ }
76
+ /** True when an allowance amount is the max of its type or ≥ 2^255. */
77
+ export function isUnlimited(amount, bits = 256) {
78
+ return amount >= UNLIMITED_THRESHOLD || amount === (1n << BigInt(bits)) - 1n;
79
+ }
80
+ /** The token's symbol if known, else its short address. */
81
+ export function tokenLabel(token, meta) {
82
+ return meta(token.toLowerCase())?.symbol ?? shortAddr(token);
83
+ }
84
+ /**
85
+ * Amount for a call argument: `UNLIMITED` for allowance-style maxima (when
86
+ * `bits` is given), `1,000.5 USDC` when decimals are known, else the raw
87
+ * integer.
88
+ */
89
+ export function argAmount(amount, token, meta, opts = {}) {
90
+ if (opts.allowanceBits !== undefined && isUnlimited(amount, opts.allowanceBits)) {
91
+ return 'UNLIMITED';
92
+ }
93
+ const m = token ? meta(token.toLowerCase()) : undefined;
94
+ if (m?.decimals !== undefined && token) {
95
+ return `${formatUnits(amount, m.decimals)} ${tokenLabel(token, meta)}`;
96
+ }
97
+ return amount.toString();
98
+ }
99
+ /**
100
+ * Amount for a headline: always names the token. `1,000.5 USDC`,
101
+ * `UNLIMITED USDC`, or `5 of 0xa0b8…eb48` when decimals are unknown.
102
+ */
103
+ export function headAmount(amount, token, meta, opts = {}) {
104
+ const label = tokenLabel(token, meta);
105
+ if (opts.allowanceBits !== undefined && isUnlimited(amount, opts.allowanceBits)) {
106
+ return `UNLIMITED ${label}`;
107
+ }
108
+ const m = meta(token.toLowerCase());
109
+ if (m?.decimals !== undefined)
110
+ return `${formatUnits(amount, m.decimals)} ${label}`;
111
+ return `${amount} of ${label}`;
112
+ }
113
+ /** Unix seconds → ISO-8601, or the raw number when out of a sane range. */
114
+ export function formatTimestamp(secs) {
115
+ if (secs <= 0n || secs > 253402300799n)
116
+ return secs.toString(); // > year 9999
117
+ return new Date(Number(secs) * 1000).toISOString().replace('.000Z', 'Z');
118
+ }
119
+ /** Bytes as 0x hex, truncated to 32 bytes with a length suffix. */
120
+ export function truncHex(hex) {
121
+ const body = hex.startsWith('0x') ? hex.slice(2) : hex;
122
+ if (body.length <= 64)
123
+ return '0x' + body;
124
+ return `0x${body.slice(0, 64)}…(${body.length / 2} bytes)`;
125
+ }
126
+ /**
127
+ * Render an ABI-decoded value for display. `short` shortens addresses
128
+ * (call-line text); the structured args keep them in full.
129
+ */
130
+ export function renderValue(type, v, short = false, depth = 0) {
131
+ if (typeof v === 'bigint')
132
+ return v.toString();
133
+ if (typeof v === 'boolean')
134
+ return v ? 'true' : 'false';
135
+ if (typeof v === 'string') {
136
+ if (type === 'address')
137
+ return short ? shortAddr(v) : v;
138
+ if (type === 'string')
139
+ return JSON.stringify(v.length > 120 ? v.slice(0, 120) + '…' : v);
140
+ return truncHex(v); // bytes / bytesN
141
+ }
142
+ if (Array.isArray(v)) {
143
+ const inner = innerTypes(type, v.length);
144
+ const MAX = 16;
145
+ const parts = v
146
+ .slice(0, MAX)
147
+ .map((x, i) => (depth > 4 ? '…' : renderValue(inner[i] ?? '', x, short, depth + 1)));
148
+ if (v.length > MAX)
149
+ parts.push(`…+${v.length - MAX} more`);
150
+ return type.startsWith('(') && !type.endsWith(']')
151
+ ? `(${parts.join(', ')})`
152
+ : `[${parts.join(', ')}]`;
153
+ }
154
+ return String(v);
155
+ }
156
+ /** Element types of an array type, or component types of a tuple type. */
157
+ function innerTypes(type, n) {
158
+ const arr = /^(.*)\[\d*\]$/.exec(type);
159
+ if (arr)
160
+ return new Array(n).fill(arr[1]);
161
+ if (type.startsWith('(') && type.endsWith(')'))
162
+ return splitTopLevel(type.slice(1, -1));
163
+ return [];
164
+ }
165
+ /** Split "a,(b,c),d[]" at top-level commas. */
166
+ export function splitTopLevel(s) {
167
+ const out = [];
168
+ let depth = 0;
169
+ let cur = '';
170
+ for (const ch of s) {
171
+ if (ch === '(')
172
+ depth++;
173
+ if (ch === ')')
174
+ depth--;
175
+ if (ch === ',' && depth === 0) {
176
+ out.push(cur);
177
+ cur = '';
178
+ }
179
+ else {
180
+ cur += ch;
181
+ }
182
+ }
183
+ if (cur !== '')
184
+ out.push(cur);
185
+ return out;
186
+ }
187
+ /**
188
+ * Strip characters that could break or forge lines in what a human reads:
189
+ * C0/C1 controls (incl. \n, \r, \t), DEL, U+2028/2029 line/paragraph
190
+ * separators and the bidi overrides/isolates. Applied at the render
191
+ * boundary to every line of preview text, the headline and the warnings —
192
+ * defence in depth behind the per-source checks (identifier-only ABI names,
193
+ * quoted revert strings, allowlisted symbols).
194
+ */
195
+ export function clean(s) {
196
+ let out = '';
197
+ for (const ch of s) {
198
+ const c = ch.codePointAt(0);
199
+ const bad = c < 0x20 ||
200
+ (c >= 0x7f && c <= 0x9f) ||
201
+ c === 0x2028 ||
202
+ c === 0x2029 ||
203
+ (c >= 0x202a && c <= 0x202e) ||
204
+ (c >= 0x2066 && c <= 0x2069) ||
205
+ c === 0x200e ||
206
+ c === 0x200f;
207
+ out += bad ? ' ' : ch;
208
+ }
209
+ return out;
210
+ }
211
+ /**
212
+ * Sanitize a token symbol read from a contract. The symbol is chosen by
213
+ * whoever deployed the token, and it lands on the user's phone and in the
214
+ * agent's context: allow a conservative printable set and a short length,
215
+ * or nothing (callers then fall back to the address).
216
+ */
217
+ export function sanitizeSymbol(s) {
218
+ if (s.length > 64)
219
+ return undefined;
220
+ let end = s.length;
221
+ while (end > 0 && s[end - 1] === '\0')
222
+ end--;
223
+ const t = s.slice(0, end).trim();
224
+ if (!/^[A-Za-z0-9.$_+-]{1,16}$/.test(t))
225
+ return undefined;
226
+ return t;
227
+ }
228
+ //# sourceMappingURL=units.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"units.js","sourceRoot":"","sources":["../../../src/preview/units.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,MAAM,CAAC,MAAM,YAAY,GAAG,4CAA4C,CAAC;AACzE,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,EAAE,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;AAC7C,iFAAiF;AACjF,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,IAAI,IAAI,CAAC;AAE9C,0EAA0E;AAC1E,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,MAAM,CAAC,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IAC7B,OAAO,CAAC,CAAC,MAAM,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AACjE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,GAAG,GAAG,IAAI,GAAG,CAAC;AAC9B,MAAM,IAAI,GAAG,2BAA2B,CAAC;AAEzC,yEAAyE;AACzE,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,CAAC;AACrC,MAAM,MAAM,GAAG,uBAAuB,CAAC;AAEvC;;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+ "version": "0.0.14",
4
4
  "mcpName": "io.github.cdrn/sigil",
5
5
  "description": "Claude can sign, but never see. MCP server + CLI that keeps private keys out of the LLM's context window.",
6
6
  "license": "Apache-2.0",