protect-mcp 0.4.2 → 0.4.3
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/README.md +1 -1
- package/dist/{chunk-7HBHIKLN.mjs → chunk-VF3OCG4D.mjs} +422 -9
- package/dist/{chunk-VWUN6AI6.mjs → chunk-VIA2B65K.mjs} +1 -1
- package/dist/cli.js +690 -93
- package/dist/cli.mjs +183 -7
- package/dist/{http-transport-RIVV2RVQ.mjs → http-transport-VLIPOPIC.mjs} +1 -1
- package/dist/index.d.mts +1429 -2
- package/dist/index.d.ts +1429 -2
- package/dist/index.js +1728 -25
- package/dist/index.mjs +1273 -3
- package/package.json +4 -3
- package/policies/cedar/clinejection.cedar +50 -0
- package/policies/cedar/terraform-destroy.cedar +44 -0
- package/policies/clinejection.json +6 -0
- package/policies/data-exfiltration.json +6 -0
- package/policies/financial-safe.json +8 -0
- package/policies/github-mcp-hijack.json +6 -0
- package/policies/terraform-destroy.json +6 -0
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ interface ProtectPolicy {
|
|
|
6
6
|
policy_engine?: PolicyEngineMode;
|
|
7
7
|
/** External PDP endpoint (when policy_engine is "external" or "hybrid") */
|
|
8
8
|
external?: ExternalPDPConfig;
|
|
9
|
+
/** Directory containing .cedar policy files (when policy_engine is "cedar") */
|
|
10
|
+
cedar_dir?: string;
|
|
9
11
|
}
|
|
10
12
|
interface ToolPolicy {
|
|
11
13
|
/**
|
|
@@ -32,7 +34,7 @@ interface ToolPolicy {
|
|
|
32
34
|
}>>;
|
|
33
35
|
}
|
|
34
36
|
type TrustTier = 'unknown' | 'signed-known' | 'evidenced' | 'privileged';
|
|
35
|
-
type PolicyEngineMode = 'built-in' | 'external' | 'hybrid';
|
|
37
|
+
type PolicyEngineMode = 'built-in' | 'external' | 'hybrid' | 'cedar';
|
|
36
38
|
interface ExternalPDPConfig {
|
|
37
39
|
/** HTTP endpoint for the external policy decision point */
|
|
38
40
|
endpoint: string;
|
|
@@ -134,6 +136,18 @@ interface DecisionLog {
|
|
|
134
136
|
tier?: TrustTier;
|
|
135
137
|
/** Credential label used (v2, never the actual secret) */
|
|
136
138
|
credential_ref?: string;
|
|
139
|
+
/** OpenTelemetry trace ID (32 hex chars) — links receipts to OTel traces */
|
|
140
|
+
otel_trace_id?: string;
|
|
141
|
+
/** OpenTelemetry span ID (16 hex chars) — links this receipt to a specific span */
|
|
142
|
+
otel_span_id?: string;
|
|
143
|
+
/** Rekor transparency log anchor (if anchored) */
|
|
144
|
+
log_anchor?: {
|
|
145
|
+
transparency_log: string;
|
|
146
|
+
log_index: number;
|
|
147
|
+
integrated_time: string;
|
|
148
|
+
receipt_hash: string;
|
|
149
|
+
verify_url: string;
|
|
150
|
+
};
|
|
137
151
|
}
|
|
138
152
|
interface ProtectConfig {
|
|
139
153
|
/** Command to spawn (first element of child process) */
|
|
@@ -294,13 +308,49 @@ interface EvaluateTierOptions {
|
|
|
294
308
|
* @param manifest - Manifest presentation from the agent (or null if none)
|
|
295
309
|
* @param opts - Evaluation options (overrides, evidence store, thresholds)
|
|
296
310
|
* @returns AdmissionResult with assigned tier
|
|
311
|
+
*
|
|
312
|
+
* @patent Patent-protected construction. Covered by Apache 2.0 patent grant
|
|
313
|
+
* for users of this code. Clean-room reimplementation requires a patent license.
|
|
314
|
+
* @see {@link https://datatracker.ietf.org/doc/draft-farley-acta-signed-receipts/}
|
|
297
315
|
*/
|
|
298
316
|
declare function evaluateTier(manifest: ManifestPresentation | null, opts?: TierOverrides | EvaluateTierOptions): AdmissionResult;
|
|
299
317
|
/**
|
|
300
318
|
* Check if a trust tier meets the minimum required tier.
|
|
319
|
+
*
|
|
320
|
+
* @patent Patent-protected construction. Covered by Apache 2.0 patent grant
|
|
321
|
+
* for users of this code. Clean-room reimplementation requires a patent license.
|
|
322
|
+
* @see {@link https://datatracker.ietf.org/doc/draft-farley-acta-signed-receipts/}
|
|
301
323
|
*/
|
|
302
324
|
declare function meetsMinTier(actual: TrustTier, required: TrustTier): boolean;
|
|
303
325
|
|
|
326
|
+
/**
|
|
327
|
+
* @scopeblind/protect-mcp — Cedar Policy Evaluator (Local WASM)
|
|
328
|
+
*
|
|
329
|
+
* Evaluates Cedar policies locally using @cedar-policy/cedar-wasm.
|
|
330
|
+
* No external server required. Same deterministic evaluation as
|
|
331
|
+
* AWS Verified Permissions / AgentCore Policy.
|
|
332
|
+
*
|
|
333
|
+
* Cedar is loaded as an optional dependency — if the WASM module
|
|
334
|
+
* isn't installed, this module exports stubs that return fallback decisions.
|
|
335
|
+
*/
|
|
336
|
+
|
|
337
|
+
interface CedarPolicySet {
|
|
338
|
+
/** Raw concatenated Cedar source */
|
|
339
|
+
source: string;
|
|
340
|
+
/** SHA-256 digest of the sorted, concatenated policy source */
|
|
341
|
+
digest: string;
|
|
342
|
+
/** Number of individual .cedar files loaded */
|
|
343
|
+
fileCount: number;
|
|
344
|
+
/** Filenames loaded */
|
|
345
|
+
files: string[];
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* MCP tool-calling gateway that intercepts JSON-RPC requests,
|
|
350
|
+
* evaluates policy, and emits signed decision receipts.
|
|
351
|
+
*
|
|
352
|
+
* @standard Standard MCP proxy pattern — JSON-RPC stdio interception.
|
|
353
|
+
*/
|
|
304
354
|
declare class ProtectGateway {
|
|
305
355
|
private child;
|
|
306
356
|
private config;
|
|
@@ -316,10 +366,19 @@ declare class ProtectGateway {
|
|
|
316
366
|
private readonly approvalNonce;
|
|
317
367
|
private currentTier;
|
|
318
368
|
private admissionResult;
|
|
369
|
+
/** Notification config for approval gates (SMS, webhook, email) */
|
|
370
|
+
private notificationConfig;
|
|
319
371
|
/** HTTP transport mode: pending response resolvers keyed by JSON-RPC id */
|
|
320
372
|
private pendingResponses;
|
|
321
373
|
private httpMode;
|
|
374
|
+
/** Loaded Cedar policy set (when policy_engine is "cedar") */
|
|
375
|
+
private cedarPolicySet;
|
|
322
376
|
constructor(config: ProtectConfig);
|
|
377
|
+
/**
|
|
378
|
+
* Set the Cedar policy set for local evaluation.
|
|
379
|
+
* Called during CLI startup when --cedar flag is used.
|
|
380
|
+
*/
|
|
381
|
+
setCedarPolicies(policySet: CedarPolicySet): void;
|
|
323
382
|
start(): Promise<void>;
|
|
324
383
|
setManifest(manifest: ManifestPresentation | null): AdmissionResult;
|
|
325
384
|
private handleClientMessage;
|
|
@@ -328,6 +387,15 @@ declare class ProtectGateway {
|
|
|
328
387
|
private injectParamsCredentials;
|
|
329
388
|
private interceptToolCall;
|
|
330
389
|
private getTierRateLimit;
|
|
390
|
+
/**
|
|
391
|
+
* Emit a decision log entry with OTel-compatible trace IDs and optional
|
|
392
|
+
* signed receipt generation.
|
|
393
|
+
*
|
|
394
|
+
* @patent Patent-protected construction — decision receipts with configurable
|
|
395
|
+
* disclosure and issuer-blind properties. Covered by Apache 2.0 patent grant
|
|
396
|
+
* for users of this code. Clean-room reimplementation requires a patent license.
|
|
397
|
+
* @see {@link https://datatracker.ietf.org/doc/draft-farley-acta-signed-receipts/}
|
|
398
|
+
*/
|
|
331
399
|
private emitDecisionLog;
|
|
332
400
|
private makeErrorResponse;
|
|
333
401
|
private sendToChild;
|
|
@@ -432,6 +500,11 @@ interface CredentialResolution {
|
|
|
432
500
|
* @param label - Credential label (e.g., "stripe_api")
|
|
433
501
|
* @param credentials - Credential configuration map
|
|
434
502
|
* @returns CredentialResolution (value is only populated on success)
|
|
503
|
+
*
|
|
504
|
+
* @patent Patent-protected construction — privacy-preserving credential presentation.
|
|
505
|
+
* Covered by Apache 2.0 patent grant for users of this code. Clean-room
|
|
506
|
+
* reimplementation requires a patent license.
|
|
507
|
+
* @see {@link https://datatracker.ietf.org/doc/draft-farley-acta-signed-receipts/}
|
|
435
508
|
*/
|
|
436
509
|
declare function resolveCredential(label: string, credentials: Record<string, CredentialConfig> | undefined): CredentialResolution;
|
|
437
510
|
/**
|
|
@@ -439,6 +512,11 @@ declare function resolveCredential(label: string, credentials: Record<string, Cr
|
|
|
439
512
|
*
|
|
440
513
|
* @param credentials - Credential configuration map
|
|
441
514
|
* @returns Array of credential labels
|
|
515
|
+
*
|
|
516
|
+
* @patent Patent-protected construction — privacy-preserving credential presentation.
|
|
517
|
+
* Covered by Apache 2.0 patent grant for users of this code. Clean-room
|
|
518
|
+
* reimplementation requires a patent license.
|
|
519
|
+
* @see {@link https://datatracker.ietf.org/doc/draft-farley-acta-signed-receipts/}
|
|
442
520
|
*/
|
|
443
521
|
declare function listCredentialLabels(credentials: Record<string, CredentialConfig> | undefined): string[];
|
|
444
522
|
/**
|
|
@@ -447,6 +525,11 @@ declare function listCredentialLabels(credentials: Record<string, CredentialConf
|
|
|
447
525
|
*
|
|
448
526
|
* @param credentials - Credential configuration map
|
|
449
527
|
* @returns Array of warnings for missing env vars
|
|
528
|
+
*
|
|
529
|
+
* @patent Patent-protected construction — privacy-preserving credential presentation.
|
|
530
|
+
* Covered by Apache 2.0 patent grant for users of this code. Clean-room
|
|
531
|
+
* reimplementation requires a patent license.
|
|
532
|
+
* @see {@link https://datatracker.ietf.org/doc/draft-farley-acta-signed-receipts/}
|
|
450
533
|
*/
|
|
451
534
|
declare function validateCredentials(credentials: Record<string, CredentialConfig> | undefined): string[];
|
|
452
535
|
|
|
@@ -467,6 +550,8 @@ declare function validateCredentials(credentials: Record<string, CredentialConfi
|
|
|
467
550
|
*
|
|
468
551
|
* @param config - Signing configuration
|
|
469
552
|
* @returns Array of warnings (empty = success)
|
|
553
|
+
*
|
|
554
|
+
* @standard RFC 8032 (Ed25519), RFC 8785 (JCS)
|
|
470
555
|
*/
|
|
471
556
|
declare function initSigning(config: SigningConfig | undefined): Promise<string[]>;
|
|
472
557
|
/**
|
|
@@ -474,6 +559,8 @@ declare function initSigning(config: SigningConfig | undefined): Promise<string[
|
|
|
474
559
|
*
|
|
475
560
|
* Returns the signed artifact JSON string, or null if signing is not configured.
|
|
476
561
|
* On signing failure, returns an unsigned artifact with a warning.
|
|
562
|
+
*
|
|
563
|
+
* @standard RFC 8032 (Ed25519), RFC 8785 (JCS)
|
|
477
564
|
*/
|
|
478
565
|
declare function signDecision(entry: DecisionLog): {
|
|
479
566
|
signed: string | null;
|
|
@@ -482,6 +569,8 @@ declare function signDecision(entry: DecisionLog): {
|
|
|
482
569
|
};
|
|
483
570
|
/**
|
|
484
571
|
* Get the signer's public key info for discovery/verification.
|
|
572
|
+
*
|
|
573
|
+
* @standard RFC 8032 (Ed25519), RFC 8785 (JCS)
|
|
485
574
|
*/
|
|
486
575
|
declare function getSignerInfo(): {
|
|
487
576
|
publicKey: string;
|
|
@@ -490,6 +579,8 @@ declare function getSignerInfo(): {
|
|
|
490
579
|
} | null;
|
|
491
580
|
/**
|
|
492
581
|
* Check if signing is available.
|
|
582
|
+
*
|
|
583
|
+
* @standard RFC 8032 (Ed25519), RFC 8785 (JCS)
|
|
493
584
|
*/
|
|
494
585
|
declare function isSigningEnabled(): boolean;
|
|
495
586
|
|
|
@@ -1007,6 +1098,11 @@ declare function isDisclosureMode(s: string): s is DisclosureMode;
|
|
|
1007
1098
|
* Does NOT verify the cryptographic signature — use verifyManifestSignature() for that.
|
|
1008
1099
|
*
|
|
1009
1100
|
* Returns an array of error strings. Empty array = valid.
|
|
1101
|
+
*
|
|
1102
|
+
* @patent Patent-protected construction — agent manifest format for portable agent
|
|
1103
|
+
* identity with evidence chains. Covered by Apache 2.0 patent grant for users of
|
|
1104
|
+
* this code. Clean-room reimplementation requires a patent license.
|
|
1105
|
+
* @see {@link https://datatracker.ietf.org/doc/draft-farley-acta-signed-receipts/}
|
|
1010
1106
|
*/
|
|
1011
1107
|
declare function validateManifest(manifest: unknown): string[];
|
|
1012
1108
|
/**
|
|
@@ -1014,7 +1110,1338 @@ declare function validateManifest(manifest: unknown): string[];
|
|
|
1014
1110
|
* Does NOT verify the cryptographic signature.
|
|
1015
1111
|
*
|
|
1016
1112
|
* Returns an array of error strings. Empty array = valid.
|
|
1113
|
+
*
|
|
1114
|
+
* @patent Patent-protected construction — evidence receipt format for portable agent
|
|
1115
|
+
* identity with evidence chains. Covered by Apache 2.0 patent grant for users of
|
|
1116
|
+
* this code. Clean-room reimplementation requires a patent license.
|
|
1117
|
+
* @see {@link https://datatracker.ietf.org/doc/draft-farley-acta-signed-receipts/}
|
|
1017
1118
|
*/
|
|
1018
1119
|
declare function validateEvidenceReceipt(receipt: unknown): string[];
|
|
1019
1120
|
|
|
1020
|
-
|
|
1121
|
+
/**
|
|
1122
|
+
* Sigstore Rekor Transparency Log Anchoring
|
|
1123
|
+
*
|
|
1124
|
+
* Anchors receipt hashes to the Sigstore Rekor transparency log,
|
|
1125
|
+
* providing independent temporal proof that a receipt existed at a
|
|
1126
|
+
* specific point in time. The inclusion proof makes backdating
|
|
1127
|
+
* receipts cryptographically detectable.
|
|
1128
|
+
*
|
|
1129
|
+
* Uses the Rekor public instance (rekor.sigstore.dev) — free, no account needed.
|
|
1130
|
+
*
|
|
1131
|
+
* Usage:
|
|
1132
|
+
* import { anchorToRekor, verifyRekorAnchor } from './rekor-anchor.js';
|
|
1133
|
+
*
|
|
1134
|
+
* // Anchor a receipt hash
|
|
1135
|
+
* const anchor = await anchorToRekor(receiptHash, signature, publicKey);
|
|
1136
|
+
*
|
|
1137
|
+
* // Verify an anchor
|
|
1138
|
+
* const valid = await verifyRekorAnchor(anchor.logIndex, receiptHash);
|
|
1139
|
+
*/
|
|
1140
|
+
interface RekorAnchor {
|
|
1141
|
+
/** Rekor log index */
|
|
1142
|
+
logIndex: number;
|
|
1143
|
+
/** Rekor entry UUID */
|
|
1144
|
+
uuid: string;
|
|
1145
|
+
/** Inclusion timestamp (RFC 3339) */
|
|
1146
|
+
integratedTime: string;
|
|
1147
|
+
/** SHA-256 hash of the receipt that was anchored */
|
|
1148
|
+
receiptHash: string;
|
|
1149
|
+
/** Rekor log ID */
|
|
1150
|
+
logID: string;
|
|
1151
|
+
/** Body of the Rekor entry (base64) */
|
|
1152
|
+
body: string;
|
|
1153
|
+
}
|
|
1154
|
+
interface RekorVerification {
|
|
1155
|
+
valid: boolean;
|
|
1156
|
+
logIndex: number;
|
|
1157
|
+
integratedTime: string;
|
|
1158
|
+
receiptHashMatch: boolean;
|
|
1159
|
+
}
|
|
1160
|
+
/**
|
|
1161
|
+
* Anchor a receipt hash to the Sigstore Rekor transparency log.
|
|
1162
|
+
*
|
|
1163
|
+
* Creates a "hashedrekord" entry containing the SHA-256 hash of the receipt,
|
|
1164
|
+
* the Ed25519 signature, and the public key. The Rekor server returns an
|
|
1165
|
+
* inclusion proof with a timestamp.
|
|
1166
|
+
*
|
|
1167
|
+
* @param receiptHash - SHA-256 hex hash of the receipt content
|
|
1168
|
+
* @param signature - Ed25519 signature (base64)
|
|
1169
|
+
* @param publicKeyPem - Ed25519 public key in PEM format
|
|
1170
|
+
* @returns RekorAnchor with log index, UUID, and timestamp
|
|
1171
|
+
*
|
|
1172
|
+
* @standard Integration with Sigstore Rekor transparency log — standard transparency anchoring.
|
|
1173
|
+
*/
|
|
1174
|
+
declare function anchorToRekor(receiptHash: string, signature: string, publicKeyPem: string): Promise<RekorAnchor>;
|
|
1175
|
+
/**
|
|
1176
|
+
* Verify that a receipt hash was anchored to Rekor at a specific log index.
|
|
1177
|
+
*
|
|
1178
|
+
* Fetches the entry from Rekor and checks that the hash matches.
|
|
1179
|
+
* This is the "trust but verify" path — anyone can check the anchor
|
|
1180
|
+
* without contacting ScopeBlind.
|
|
1181
|
+
*
|
|
1182
|
+
* @param logIndex - The Rekor log index to verify
|
|
1183
|
+
* @param expectedHash - The expected SHA-256 hash of the receipt
|
|
1184
|
+
*
|
|
1185
|
+
* @standard Integration with Sigstore Rekor transparency log — standard transparency anchoring.
|
|
1186
|
+
*/
|
|
1187
|
+
declare function verifyRekorAnchor(logIndex: number, expectedHash: string): Promise<RekorVerification>;
|
|
1188
|
+
/**
|
|
1189
|
+
* Compute the SHA-256 hash of a receipt for anchoring.
|
|
1190
|
+
* Uses JCS-compatible canonical JSON (sorted keys).
|
|
1191
|
+
*
|
|
1192
|
+
* @standard RFC 8785 (JCS), SHA-256
|
|
1193
|
+
*/
|
|
1194
|
+
declare function hashReceipt(receipt: Record<string, unknown>): string;
|
|
1195
|
+
/**
|
|
1196
|
+
* Create a log_anchor field for embedding in receipts.
|
|
1197
|
+
* This field can be added to any Acta receipt to provide
|
|
1198
|
+
* temporal proof of existence.
|
|
1199
|
+
*
|
|
1200
|
+
* @standard Integration with Sigstore Rekor transparency log — standard transparency anchoring.
|
|
1201
|
+
*/
|
|
1202
|
+
declare function createLogAnchorField(anchor: RekorAnchor): {
|
|
1203
|
+
transparency_log: string;
|
|
1204
|
+
log_index: number;
|
|
1205
|
+
integrated_time: string;
|
|
1206
|
+
receipt_hash: string;
|
|
1207
|
+
verify_url: string;
|
|
1208
|
+
};
|
|
1209
|
+
|
|
1210
|
+
/**
|
|
1211
|
+
* Hash-Based Selective Disclosure for Veritas Acta Receipts
|
|
1212
|
+
*
|
|
1213
|
+
* Enables per-field redaction of receipt payloads while preserving
|
|
1214
|
+
* signature validity. Uses salted SHA-256 commitments — the receipt
|
|
1215
|
+
* structure and non-redacted fields remain verifiable, but redacted
|
|
1216
|
+
* fields are replaced with their salted hash.
|
|
1217
|
+
*
|
|
1218
|
+
* This is NOT zero-knowledge proof — it's practical, fast, and
|
|
1219
|
+
* covers 90% of the privacy use cases:
|
|
1220
|
+
* - Prove an agent followed HIPAA policy without revealing patient_id
|
|
1221
|
+
* - Prove a tool call was rate-limited without revealing the API endpoint
|
|
1222
|
+
* - Prove a deny decision occurred without revealing the prompt
|
|
1223
|
+
*
|
|
1224
|
+
* The salt is per-field and per-receipt, preventing rainbow table attacks.
|
|
1225
|
+
* The field owner (receipt issuer) holds the salts and can selectively
|
|
1226
|
+
* reveal fields to specific auditors.
|
|
1227
|
+
*
|
|
1228
|
+
* Usage:
|
|
1229
|
+
* import { redactFields, revealField, verifyRedactedReceipt } from './selective-disclosure.js';
|
|
1230
|
+
*
|
|
1231
|
+
* // Redact sensitive fields
|
|
1232
|
+
* const { redacted, salts } = redactFields(receipt, ['patient_id', 'ssn', 'timestamp']);
|
|
1233
|
+
*
|
|
1234
|
+
* // The redacted receipt has: "patient_id": "sha256:salt+..."
|
|
1235
|
+
* // The signature still verifies against the original
|
|
1236
|
+
*
|
|
1237
|
+
* // Reveal a specific field to an auditor
|
|
1238
|
+
* const revealed = revealField(redacted, salts, 'patient_id');
|
|
1239
|
+
*
|
|
1240
|
+
* // Verify a redacted receipt (checks that redacted fields are valid commitments)
|
|
1241
|
+
* const valid = verifyRedactedReceipt(redacted, originalSignature, publicKey);
|
|
1242
|
+
*/
|
|
1243
|
+
interface RedactionSalt {
|
|
1244
|
+
field: string;
|
|
1245
|
+
salt: string;
|
|
1246
|
+
originalValue: unknown;
|
|
1247
|
+
}
|
|
1248
|
+
interface RedactedResult {
|
|
1249
|
+
/** The receipt with sensitive fields replaced by salted commitments */
|
|
1250
|
+
redacted: Record<string, unknown>;
|
|
1251
|
+
/** The salts needed to reveal each redacted field */
|
|
1252
|
+
salts: RedactionSalt[];
|
|
1253
|
+
/** Fields that were redacted */
|
|
1254
|
+
redactedFields: string[];
|
|
1255
|
+
/** SHA-256 hash of the original (unredacted) receipt for verification */
|
|
1256
|
+
originalHash: string;
|
|
1257
|
+
}
|
|
1258
|
+
/**
|
|
1259
|
+
* Redact specified fields in a receipt payload, replacing them with
|
|
1260
|
+
* salted SHA-256 commitments.
|
|
1261
|
+
*
|
|
1262
|
+
* @param receipt - The full receipt object
|
|
1263
|
+
* @param fieldsToRedact - Array of field paths to redact (dot notation for nested: "payload.patient_id")
|
|
1264
|
+
* @returns RedactedResult with the redacted receipt and the salts
|
|
1265
|
+
*
|
|
1266
|
+
* @patent Patent-protected construction. Covered by Apache 2.0 patent grant
|
|
1267
|
+
* for users of this code. Clean-room reimplementation requires a patent license.
|
|
1268
|
+
* @see {@link https://datatracker.ietf.org/doc/draft-farley-acta-signed-receipts/}
|
|
1269
|
+
*/
|
|
1270
|
+
declare function redactFields(receipt: Record<string, unknown>, fieldsToRedact: string[]): RedactedResult;
|
|
1271
|
+
/**
|
|
1272
|
+
* Reveal a previously redacted field using its salt.
|
|
1273
|
+
*
|
|
1274
|
+
* @param redactedReceipt - The redacted receipt
|
|
1275
|
+
* @param salts - The salt array from redactFields()
|
|
1276
|
+
* @param fieldPath - The field to reveal (dot notation)
|
|
1277
|
+
* @returns A new receipt with the specified field revealed
|
|
1278
|
+
*
|
|
1279
|
+
* @patent Patent-protected construction. Covered by Apache 2.0 patent grant
|
|
1280
|
+
* for users of this code. Clean-room reimplementation requires a patent license.
|
|
1281
|
+
* @see {@link https://datatracker.ietf.org/doc/draft-farley-acta-signed-receipts/}
|
|
1282
|
+
*/
|
|
1283
|
+
declare function revealField(redactedReceipt: Record<string, unknown>, salts: RedactionSalt[], fieldPath: string): Record<string, unknown>;
|
|
1284
|
+
/**
|
|
1285
|
+
* Verify that a redacted field's commitment matches the revealed value.
|
|
1286
|
+
*
|
|
1287
|
+
* An auditor can check: "does sha256(salt + value) equal the commitment
|
|
1288
|
+
* in the receipt?" without needing the issuer's cooperation.
|
|
1289
|
+
*
|
|
1290
|
+
* @param commitment - The commitment string from _commitments
|
|
1291
|
+
* @param salt - The salt (hex)
|
|
1292
|
+
* @param value - The claimed original value
|
|
1293
|
+
* @returns true if the commitment is valid
|
|
1294
|
+
*
|
|
1295
|
+
* @patent Patent-protected construction. Covered by Apache 2.0 patent grant
|
|
1296
|
+
* for users of this code. Clean-room reimplementation requires a patent license.
|
|
1297
|
+
* @see {@link https://datatracker.ietf.org/doc/draft-farley-acta-signed-receipts/}
|
|
1298
|
+
*/
|
|
1299
|
+
declare function verifyCommitment(commitment: string, salt: string, value: unknown): boolean;
|
|
1300
|
+
/**
|
|
1301
|
+
* Verify all commitments in a redacted receipt given a set of salts.
|
|
1302
|
+
*
|
|
1303
|
+
* @param redactedReceipt - The redacted receipt with _commitments
|
|
1304
|
+
* @param salts - The salts for all redacted fields
|
|
1305
|
+
* @returns Object with valid flag and per-field results
|
|
1306
|
+
*
|
|
1307
|
+
* @patent Patent-protected construction. Covered by Apache 2.0 patent grant
|
|
1308
|
+
* for users of this code. Clean-room reimplementation requires a patent license.
|
|
1309
|
+
* @see {@link https://datatracker.ietf.org/doc/draft-farley-acta-signed-receipts/}
|
|
1310
|
+
*/
|
|
1311
|
+
declare function verifyAllCommitments(redactedReceipt: Record<string, unknown>, salts: RedactionSalt[]): {
|
|
1312
|
+
valid: boolean;
|
|
1313
|
+
fields: Record<string, boolean>;
|
|
1314
|
+
};
|
|
1315
|
+
/**
|
|
1316
|
+
* Create a disclosure package for a specific auditor.
|
|
1317
|
+
* Contains only the salts for fields the auditor needs to see.
|
|
1318
|
+
*
|
|
1319
|
+
* @param allSalts - Full salt array from redactFields()
|
|
1320
|
+
* @param fieldsToDisclose - Array of field paths to include
|
|
1321
|
+
* @returns Disclosure package (JSON-serializable)
|
|
1322
|
+
*
|
|
1323
|
+
* @patent Patent-protected construction. Covered by Apache 2.0 patent grant
|
|
1324
|
+
* for users of this code. Clean-room reimplementation requires a patent license.
|
|
1325
|
+
* @see {@link https://datatracker.ietf.org/doc/draft-farley-acta-signed-receipts/}
|
|
1326
|
+
*/
|
|
1327
|
+
declare function createDisclosurePackage(allSalts: RedactionSalt[], fieldsToDisclose: string[]): {
|
|
1328
|
+
version: string;
|
|
1329
|
+
disclosed_fields: string[];
|
|
1330
|
+
salts: Array<{
|
|
1331
|
+
field: string;
|
|
1332
|
+
salt: string;
|
|
1333
|
+
value: unknown;
|
|
1334
|
+
}>;
|
|
1335
|
+
};
|
|
1336
|
+
|
|
1337
|
+
/**
|
|
1338
|
+
* Notification system for protect-mcp approval gates.
|
|
1339
|
+
* Sends SMS (Twilio), webhook, or browser push notifications
|
|
1340
|
+
* when a tool call requires human approval.
|
|
1341
|
+
*/
|
|
1342
|
+
interface NotificationConfig {
|
|
1343
|
+
/** Twilio SMS notification */
|
|
1344
|
+
sms?: {
|
|
1345
|
+
accountSid: string;
|
|
1346
|
+
authToken: string;
|
|
1347
|
+
from: string;
|
|
1348
|
+
to: string;
|
|
1349
|
+
};
|
|
1350
|
+
/** Webhook notification (Slack, PagerDuty, custom) */
|
|
1351
|
+
webhook?: {
|
|
1352
|
+
url: string;
|
|
1353
|
+
method?: "POST" | "PUT";
|
|
1354
|
+
headers?: Record<string, string>;
|
|
1355
|
+
/** Template: 'slack' | 'pagerduty' | 'custom' */
|
|
1356
|
+
template?: "slack" | "pagerduty" | "custom";
|
|
1357
|
+
};
|
|
1358
|
+
/** Email notification */
|
|
1359
|
+
email?: {
|
|
1360
|
+
to: string;
|
|
1361
|
+
/** Uses Resend API if configured, falls back to SMTP */
|
|
1362
|
+
resendApiKey?: string;
|
|
1363
|
+
};
|
|
1364
|
+
}
|
|
1365
|
+
interface ApprovalNotification {
|
|
1366
|
+
requestId: string;
|
|
1367
|
+
toolName: string;
|
|
1368
|
+
agentId?: string;
|
|
1369
|
+
policyName?: string;
|
|
1370
|
+
reason: string;
|
|
1371
|
+
traceUrl?: string;
|
|
1372
|
+
approveUrl?: string;
|
|
1373
|
+
timestamp: string;
|
|
1374
|
+
}
|
|
1375
|
+
/**
|
|
1376
|
+
* Send approval notification through configured channels.
|
|
1377
|
+
* Non-blocking — errors are logged, not thrown.
|
|
1378
|
+
*/
|
|
1379
|
+
declare function sendApprovalNotification(config: NotificationConfig, notification: ApprovalNotification): Promise<void>;
|
|
1380
|
+
/**
|
|
1381
|
+
* Parse notification config from environment variables.
|
|
1382
|
+
* SCOPEBLIND_SMS_TO, SCOPEBLIND_TWILIO_SID, etc.
|
|
1383
|
+
*/
|
|
1384
|
+
declare function parseNotificationConfigFromEnv(): NotificationConfig | null;
|
|
1385
|
+
|
|
1386
|
+
/**
|
|
1387
|
+
* Hugging Face Dataset Export
|
|
1388
|
+
*
|
|
1389
|
+
* Exports Veritas Acta receipt chains as HF-compatible datasets.
|
|
1390
|
+
* Produces JSONL format with structured fields for ML research.
|
|
1391
|
+
*
|
|
1392
|
+
* Usage:
|
|
1393
|
+
* npx protect-mcp export-hf --output dataset.jsonl
|
|
1394
|
+
* npx protect-mcp export-hf --output dataset.jsonl --format parquet
|
|
1395
|
+
*/
|
|
1396
|
+
interface HFReceiptRow {
|
|
1397
|
+
/** Unique receipt identifier */
|
|
1398
|
+
receipt_id: string;
|
|
1399
|
+
/** Receipt type: decision, execution, outcome, policy_load, observation, approval */
|
|
1400
|
+
receipt_type: string;
|
|
1401
|
+
/** Tool that was called */
|
|
1402
|
+
tool_name: string | null;
|
|
1403
|
+
/** Decision verdict: allow, deny, null */
|
|
1404
|
+
decision: string | null;
|
|
1405
|
+
/** Agent identifier (pseudonymous) */
|
|
1406
|
+
agent_id: string | null;
|
|
1407
|
+
/** Issuer identifier */
|
|
1408
|
+
issuer_id: string;
|
|
1409
|
+
/** ISO 8601 timestamp */
|
|
1410
|
+
timestamp: string;
|
|
1411
|
+
/** SHA-256 hash of the active policy at decision time */
|
|
1412
|
+
policy_hash: string | null;
|
|
1413
|
+
/** Typed causal edges to other receipts */
|
|
1414
|
+
edges: Array<{
|
|
1415
|
+
receipt_id: string;
|
|
1416
|
+
relation: string;
|
|
1417
|
+
}>;
|
|
1418
|
+
/** Number of edges (for quick filtering) */
|
|
1419
|
+
edge_count: number;
|
|
1420
|
+
/** Ed25519 signature (hex) */
|
|
1421
|
+
signature: string | null;
|
|
1422
|
+
/** Whether the receipt has a valid signature */
|
|
1423
|
+
signed: boolean;
|
|
1424
|
+
/** Context hash for selective disclosure */
|
|
1425
|
+
context_hash: string | null;
|
|
1426
|
+
/** Chain ID linking related receipts */
|
|
1427
|
+
chain_id: string | null;
|
|
1428
|
+
}
|
|
1429
|
+
interface HFDatasetMetadata {
|
|
1430
|
+
/** Dataset name */
|
|
1431
|
+
name: string;
|
|
1432
|
+
/** Description */
|
|
1433
|
+
description: string;
|
|
1434
|
+
/** Number of rows */
|
|
1435
|
+
num_rows: number;
|
|
1436
|
+
/** Receipt type distribution */
|
|
1437
|
+
type_distribution: Record<string, number>;
|
|
1438
|
+
/** Decision distribution */
|
|
1439
|
+
decision_distribution: Record<string, number>;
|
|
1440
|
+
/** Time range */
|
|
1441
|
+
time_range: {
|
|
1442
|
+
from: string;
|
|
1443
|
+
to: string;
|
|
1444
|
+
};
|
|
1445
|
+
/** Unique agents */
|
|
1446
|
+
unique_agents: number;
|
|
1447
|
+
/** Unique tools */
|
|
1448
|
+
unique_tools: number;
|
|
1449
|
+
/** Export timestamp */
|
|
1450
|
+
exported_at: string;
|
|
1451
|
+
/** License */
|
|
1452
|
+
license: "MIT";
|
|
1453
|
+
/** Tags for HF Hub */
|
|
1454
|
+
tags: string[];
|
|
1455
|
+
}
|
|
1456
|
+
/**
|
|
1457
|
+
* Convert raw receipt objects to HF-compatible rows.
|
|
1458
|
+
*/
|
|
1459
|
+
declare function receiptsToHFRows(receipts: Record<string, unknown>[]): HFReceiptRow[];
|
|
1460
|
+
/**
|
|
1461
|
+
* Generate dataset metadata for HF Hub.
|
|
1462
|
+
*/
|
|
1463
|
+
declare function generateHFMetadata(rows: HFReceiptRow[], name?: string): HFDatasetMetadata;
|
|
1464
|
+
/**
|
|
1465
|
+
* Export receipts as JSONL (one JSON object per line).
|
|
1466
|
+
*/
|
|
1467
|
+
declare function exportJSONL(rows: HFReceiptRow[]): string;
|
|
1468
|
+
/**
|
|
1469
|
+
* Generate a HuggingFace dataset card (README.md) for the dataset repo.
|
|
1470
|
+
*/
|
|
1471
|
+
declare function generateDatasetCard(metadata: HFDatasetMetadata): string;
|
|
1472
|
+
|
|
1473
|
+
/**
|
|
1474
|
+
* WebAuthn/Passkey Approval for protect-mcp Human-in-the-Loop Gates
|
|
1475
|
+
*
|
|
1476
|
+
* Enables biometric (FaceID, TouchID, Windows Hello, YubiKey) approval
|
|
1477
|
+
* of agent tool calls. When an agent requests a tool that requires
|
|
1478
|
+
* human approval, the system generates a WebAuthn challenge. The human
|
|
1479
|
+
* authenticates with their biometric device, producing a cryptographic
|
|
1480
|
+
* proof that a specific human authorized a specific action.
|
|
1481
|
+
*
|
|
1482
|
+
* The WebAuthn assertion is embedded in the approval receipt as the
|
|
1483
|
+
* `authenticator_data` field, creating an unforgeable binding between
|
|
1484
|
+
* biological intent and machine execution.
|
|
1485
|
+
*
|
|
1486
|
+
* Flow:
|
|
1487
|
+
* 1. Agent requests `db_write` → policy says `require_approval`
|
|
1488
|
+
* 2. protect-mcp generates a WebAuthn challenge containing the tool
|
|
1489
|
+
* name, request ID, and a timestamp
|
|
1490
|
+
* 3. Human receives notification (SMS/Slack/browser) with the challenge
|
|
1491
|
+
* 4. Human authenticates with FaceID/TouchID/YubiKey
|
|
1492
|
+
* 5. The WebAuthn assertion is verified server-side
|
|
1493
|
+
* 6. A signed approval receipt is emitted with the authenticator data
|
|
1494
|
+
* 7. The agent's tool call is unblocked
|
|
1495
|
+
*
|
|
1496
|
+
* Usage:
|
|
1497
|
+
* import { createApprovalChallenge, verifyApprovalAssertion } from './webauthn-approval.js';
|
|
1498
|
+
*
|
|
1499
|
+
* // Server-side: create challenge
|
|
1500
|
+
* const challenge = createApprovalChallenge(requestId, toolName, agentId);
|
|
1501
|
+
*
|
|
1502
|
+
* // Client-side: browser calls navigator.credentials.get() with challenge
|
|
1503
|
+
* // ... user authenticates with biometric ...
|
|
1504
|
+
*
|
|
1505
|
+
* // Server-side: verify the assertion
|
|
1506
|
+
* const result = verifyApprovalAssertion(challenge, assertion, credentialId);
|
|
1507
|
+
*/
|
|
1508
|
+
interface ApprovalChallenge {
|
|
1509
|
+
/** Random challenge bytes (base64url) */
|
|
1510
|
+
challenge: string;
|
|
1511
|
+
/** Request ID of the tool call being approved */
|
|
1512
|
+
requestId: string;
|
|
1513
|
+
/** Tool name being approved */
|
|
1514
|
+
toolName: string;
|
|
1515
|
+
/** Agent requesting the approval */
|
|
1516
|
+
agentId?: string;
|
|
1517
|
+
/** Timestamp when challenge was created */
|
|
1518
|
+
createdAt: string;
|
|
1519
|
+
/** Challenge expiry (seconds) */
|
|
1520
|
+
timeoutSeconds: number;
|
|
1521
|
+
/** Relying party ID (domain) */
|
|
1522
|
+
rpId: string;
|
|
1523
|
+
/** SHA-256 hash of the challenge context (for receipt embedding) */
|
|
1524
|
+
contextHash: string;
|
|
1525
|
+
}
|
|
1526
|
+
interface ApprovalAssertion {
|
|
1527
|
+
/** Credential ID used (base64url) */
|
|
1528
|
+
credentialId: string;
|
|
1529
|
+
/** Authenticator data (base64url) */
|
|
1530
|
+
authenticatorData: string;
|
|
1531
|
+
/** Client data JSON (base64url) */
|
|
1532
|
+
clientDataJSON: string;
|
|
1533
|
+
/** Signature (base64url) */
|
|
1534
|
+
signature: string;
|
|
1535
|
+
/** User handle (base64url, optional) */
|
|
1536
|
+
userHandle?: string;
|
|
1537
|
+
}
|
|
1538
|
+
interface ApprovalResult {
|
|
1539
|
+
/** Whether the assertion is valid */
|
|
1540
|
+
valid: boolean;
|
|
1541
|
+
/** The credential ID used */
|
|
1542
|
+
credentialId: string;
|
|
1543
|
+
/** Authenticator type detected */
|
|
1544
|
+
authenticatorType: 'platform' | 'cross-platform' | 'unknown';
|
|
1545
|
+
/** Whether user verification was performed (biometric) */
|
|
1546
|
+
userVerified: boolean;
|
|
1547
|
+
/** Signature counter (for cloning detection) */
|
|
1548
|
+
signCount: number;
|
|
1549
|
+
/** Context hash that was signed */
|
|
1550
|
+
contextHash: string;
|
|
1551
|
+
/** Timestamp of approval */
|
|
1552
|
+
approvedAt: string;
|
|
1553
|
+
}
|
|
1554
|
+
/**
|
|
1555
|
+
* Create a WebAuthn challenge for approving a tool call.
|
|
1556
|
+
*
|
|
1557
|
+
* The challenge contains the tool name and request ID so the
|
|
1558
|
+
* approval is cryptographically bound to a specific action.
|
|
1559
|
+
*
|
|
1560
|
+
* @param requestId - The request ID of the pending tool call
|
|
1561
|
+
* @param toolName - The tool being approved
|
|
1562
|
+
* @param agentId - The agent requesting approval (optional)
|
|
1563
|
+
* @param rpId - Relying party ID (default: scopeblind.com)
|
|
1564
|
+
* @param timeoutSeconds - Challenge timeout (default: 300 = 5 minutes)
|
|
1565
|
+
*/
|
|
1566
|
+
declare function createApprovalChallenge(requestId: string, toolName: string, agentId?: string, rpId?: string, timeoutSeconds?: number): ApprovalChallenge;
|
|
1567
|
+
/**
|
|
1568
|
+
* Generate the WebAuthn PublicKeyCredentialRequestOptions
|
|
1569
|
+
* that the browser needs to call navigator.credentials.get().
|
|
1570
|
+
*
|
|
1571
|
+
* This is sent to the client for the biometric prompt.
|
|
1572
|
+
*/
|
|
1573
|
+
declare function toCredentialRequestOptions(challenge: ApprovalChallenge, allowCredentials?: Array<{
|
|
1574
|
+
id: string;
|
|
1575
|
+
type: 'public-key';
|
|
1576
|
+
}>): {
|
|
1577
|
+
publicKey: {
|
|
1578
|
+
challenge: ArrayBuffer;
|
|
1579
|
+
rpId: string;
|
|
1580
|
+
timeout: number;
|
|
1581
|
+
userVerification: 'required';
|
|
1582
|
+
allowCredentials?: Array<{
|
|
1583
|
+
id: ArrayBuffer;
|
|
1584
|
+
type: 'public-key';
|
|
1585
|
+
}>;
|
|
1586
|
+
};
|
|
1587
|
+
};
|
|
1588
|
+
/**
|
|
1589
|
+
* Verify a WebAuthn assertion from the client.
|
|
1590
|
+
*
|
|
1591
|
+
* This is a simplified verification that checks the structure
|
|
1592
|
+
* and extracts the authenticator data. For production use with
|
|
1593
|
+
* full signature verification, use the @simplewebauthn/server package.
|
|
1594
|
+
*
|
|
1595
|
+
* @param challenge - The original challenge
|
|
1596
|
+
* @param assertion - The assertion from navigator.credentials.get()
|
|
1597
|
+
* @returns ApprovalResult with verification details
|
|
1598
|
+
*/
|
|
1599
|
+
declare function verifyApprovalAssertion(challenge: ApprovalChallenge, assertion: ApprovalAssertion): ApprovalResult;
|
|
1600
|
+
/**
|
|
1601
|
+
* Create the approval receipt payload for embedding in an Acta receipt.
|
|
1602
|
+
*
|
|
1603
|
+
* This is the data that gets signed into the DAG as an acta:approval node,
|
|
1604
|
+
* proving a human biometrically authorized a specific machine action.
|
|
1605
|
+
*/
|
|
1606
|
+
declare function createApprovalReceiptPayload(challenge: ApprovalChallenge, result: ApprovalResult): {
|
|
1607
|
+
type: 'acta:approval';
|
|
1608
|
+
approval_method: 'webauthn';
|
|
1609
|
+
tool_name: string;
|
|
1610
|
+
request_id: string;
|
|
1611
|
+
agent_id?: string;
|
|
1612
|
+
authenticator_type: string;
|
|
1613
|
+
user_verified: boolean;
|
|
1614
|
+
context_hash: string;
|
|
1615
|
+
approved_at: string;
|
|
1616
|
+
credential_id_hash: string;
|
|
1617
|
+
};
|
|
1618
|
+
|
|
1619
|
+
/**
|
|
1620
|
+
* W3C DID/VC Mapping for ScopeBlind Passport Manifests
|
|
1621
|
+
*
|
|
1622
|
+
* Maps passport manifests to W3C Verifiable Credential format
|
|
1623
|
+
* and generates did:key identifiers from Ed25519 public keys.
|
|
1624
|
+
*
|
|
1625
|
+
* @standard W3C DID/VC interoperability — standard mapping, not patent-protected.
|
|
1626
|
+
* Implements W3C Decentralized Identifiers (DID) v1.0 and Verifiable Credentials
|
|
1627
|
+
* Data Model v1.1.
|
|
1628
|
+
*/
|
|
1629
|
+
/**
|
|
1630
|
+
* Generate a did:key identifier from an Ed25519 public key (hex).
|
|
1631
|
+
*
|
|
1632
|
+
* @standard W3C DID/VC interoperability — standard mapping, not patent-protected.
|
|
1633
|
+
*/
|
|
1634
|
+
declare function ed25519ToDIDKey(publicKeyHex: string): string;
|
|
1635
|
+
/**
|
|
1636
|
+
* Convert a passport manifest to a W3C Verifiable Credential.
|
|
1637
|
+
*
|
|
1638
|
+
* @standard W3C DID/VC interoperability — standard mapping, not patent-protected.
|
|
1639
|
+
*/
|
|
1640
|
+
declare function manifestToVC(manifest: {
|
|
1641
|
+
agent_id: string;
|
|
1642
|
+
display_name?: string;
|
|
1643
|
+
public_key: string;
|
|
1644
|
+
capabilities?: string[];
|
|
1645
|
+
policy_digest?: string;
|
|
1646
|
+
created_at?: string;
|
|
1647
|
+
signature?: string;
|
|
1648
|
+
}): {
|
|
1649
|
+
'@context': string[];
|
|
1650
|
+
type: string[];
|
|
1651
|
+
issuer: string;
|
|
1652
|
+
issuanceDate: string;
|
|
1653
|
+
credentialSubject: Record<string, unknown>;
|
|
1654
|
+
proof?: Record<string, unknown>;
|
|
1655
|
+
};
|
|
1656
|
+
/**
|
|
1657
|
+
* Convert a decision receipt to a W3C Verifiable Presentation.
|
|
1658
|
+
*
|
|
1659
|
+
* @standard W3C DID/VC interoperability — standard mapping, not patent-protected.
|
|
1660
|
+
*/
|
|
1661
|
+
declare function receiptToVP(receipt: Record<string, unknown>, issuerPublicKey: string): {
|
|
1662
|
+
'@context': string[];
|
|
1663
|
+
type: string[];
|
|
1664
|
+
holder: string;
|
|
1665
|
+
verifiableCredential: Record<string, unknown>[];
|
|
1666
|
+
};
|
|
1667
|
+
|
|
1668
|
+
/**
|
|
1669
|
+
* E2B MicroVM Sandboxing for Agent Evaluation
|
|
1670
|
+
*
|
|
1671
|
+
* Provides isolated, disposable execution environments for testing
|
|
1672
|
+
* AI agent tool calls safely. Agents can run real MCP tools
|
|
1673
|
+
* (including destructive operations) inside sandboxes without
|
|
1674
|
+
* affecting the host system.
|
|
1675
|
+
*
|
|
1676
|
+
* Uses E2B (e2b.dev) for sub-second microVM startup, or falls back
|
|
1677
|
+
* to Docker containers for self-hosted deployments.
|
|
1678
|
+
*
|
|
1679
|
+
* Every tool call inside the sandbox produces a signed receipt,
|
|
1680
|
+
* creating a verifiable "safety transcript" of the agent's behavior.
|
|
1681
|
+
*
|
|
1682
|
+
* Usage:
|
|
1683
|
+
* import { createSandbox, runInSandbox, destroySandbox } from './sandbox.js';
|
|
1684
|
+
*
|
|
1685
|
+
* // Create a disposable sandbox
|
|
1686
|
+
* const sandbox = await createSandbox({ template: 'node-20' });
|
|
1687
|
+
*
|
|
1688
|
+
* // Run an agent's tool call inside the sandbox
|
|
1689
|
+
* const result = await runInSandbox(sandbox, {
|
|
1690
|
+
* tool: 'execute_command',
|
|
1691
|
+
* args: { command: 'npm test' },
|
|
1692
|
+
* });
|
|
1693
|
+
*
|
|
1694
|
+
* // Sandbox is destroyed after evaluation
|
|
1695
|
+
* await destroySandbox(sandbox);
|
|
1696
|
+
*/
|
|
1697
|
+
interface SandboxConfig {
|
|
1698
|
+
/** E2B template (e.g., 'node-20', 'python-3.11') or Docker image */
|
|
1699
|
+
template: string;
|
|
1700
|
+
/** Timeout in seconds (default: 300 = 5 minutes) */
|
|
1701
|
+
timeoutSeconds?: number;
|
|
1702
|
+
/** Maximum memory in MB (default: 512) */
|
|
1703
|
+
memoryMB?: number;
|
|
1704
|
+
/** Files to mount into the sandbox */
|
|
1705
|
+
files?: Array<{
|
|
1706
|
+
path: string;
|
|
1707
|
+
content: string;
|
|
1708
|
+
}>;
|
|
1709
|
+
/** Environment variables */
|
|
1710
|
+
env?: Record<string, string>;
|
|
1711
|
+
/** Whether to use E2B cloud or local Docker (default: 'e2b') */
|
|
1712
|
+
runtime?: 'e2b' | 'docker';
|
|
1713
|
+
/** E2B API key (from env E2B_API_KEY if not provided) */
|
|
1714
|
+
apiKey?: string;
|
|
1715
|
+
}
|
|
1716
|
+
interface Sandbox {
|
|
1717
|
+
/** Unique sandbox ID */
|
|
1718
|
+
id: string;
|
|
1719
|
+
/** Runtime type */
|
|
1720
|
+
runtime: 'e2b' | 'docker';
|
|
1721
|
+
/** Creation timestamp */
|
|
1722
|
+
createdAt: string;
|
|
1723
|
+
/** Status */
|
|
1724
|
+
status: 'running' | 'completed' | 'failed' | 'destroyed';
|
|
1725
|
+
/** Tool call receipts generated inside the sandbox */
|
|
1726
|
+
receipts: SandboxReceipt[];
|
|
1727
|
+
}
|
|
1728
|
+
interface SandboxToolCall {
|
|
1729
|
+
/** Tool name to execute */
|
|
1730
|
+
tool: string;
|
|
1731
|
+
/** Tool arguments */
|
|
1732
|
+
args: Record<string, unknown>;
|
|
1733
|
+
}
|
|
1734
|
+
interface SandboxResult {
|
|
1735
|
+
/** Whether the tool call succeeded */
|
|
1736
|
+
success: boolean;
|
|
1737
|
+
/** Tool output */
|
|
1738
|
+
output: string;
|
|
1739
|
+
/** Error message if failed */
|
|
1740
|
+
error?: string;
|
|
1741
|
+
/** Execution time in milliseconds */
|
|
1742
|
+
durationMs: number;
|
|
1743
|
+
/** Exit code (for commands) */
|
|
1744
|
+
exitCode?: number;
|
|
1745
|
+
}
|
|
1746
|
+
interface SandboxReceipt {
|
|
1747
|
+
/** Tool that was called */
|
|
1748
|
+
tool: string;
|
|
1749
|
+
/** Decision (from protect-mcp policy evaluation) */
|
|
1750
|
+
decision: 'allow' | 'deny' | 'require_approval';
|
|
1751
|
+
/** Whether it was executed */
|
|
1752
|
+
executed: boolean;
|
|
1753
|
+
/** Result if executed */
|
|
1754
|
+
result?: SandboxResult;
|
|
1755
|
+
/** Timestamp */
|
|
1756
|
+
timestamp: string;
|
|
1757
|
+
/** Policy rule that matched */
|
|
1758
|
+
policyRule?: string;
|
|
1759
|
+
}
|
|
1760
|
+
interface SafetyTranscript {
|
|
1761
|
+
/** Sandbox ID */
|
|
1762
|
+
sandboxId: string;
|
|
1763
|
+
/** Template used */
|
|
1764
|
+
template: string;
|
|
1765
|
+
/** Total tool calls attempted */
|
|
1766
|
+
totalCalls: number;
|
|
1767
|
+
/** Calls allowed */
|
|
1768
|
+
allowed: number;
|
|
1769
|
+
/** Calls denied */
|
|
1770
|
+
denied: number;
|
|
1771
|
+
/** Calls requiring approval */
|
|
1772
|
+
requireApproval: number;
|
|
1773
|
+
/** Success rate of executed calls */
|
|
1774
|
+
successRate: number;
|
|
1775
|
+
/** All receipts */
|
|
1776
|
+
receipts: SandboxReceipt[];
|
|
1777
|
+
/** Duration of the evaluation */
|
|
1778
|
+
durationMs: number;
|
|
1779
|
+
/** Timestamp */
|
|
1780
|
+
evaluatedAt: string;
|
|
1781
|
+
/** Safety score (0-100) */
|
|
1782
|
+
safetyScore: number;
|
|
1783
|
+
}
|
|
1784
|
+
/**
|
|
1785
|
+
* Create a disposable sandbox for agent evaluation.
|
|
1786
|
+
*
|
|
1787
|
+
* If E2B_API_KEY is set, uses E2B cloud microVMs.
|
|
1788
|
+
* Otherwise, falls back to local Docker containers.
|
|
1789
|
+
*/
|
|
1790
|
+
declare function createSandbox(config: SandboxConfig): Promise<Sandbox>;
|
|
1791
|
+
/**
|
|
1792
|
+
* Run a tool call inside the sandbox with protect-mcp policy evaluation.
|
|
1793
|
+
*/
|
|
1794
|
+
declare function runInSandbox(sandbox: Sandbox, toolCall: SandboxToolCall, policy?: Record<string, unknown>): Promise<SandboxReceipt>;
|
|
1795
|
+
/**
|
|
1796
|
+
* Generate a safety transcript from a sandbox evaluation.
|
|
1797
|
+
* This is the "graduation certificate" for an agent.
|
|
1798
|
+
*/
|
|
1799
|
+
declare function generateSafetyTranscript(sandbox: Sandbox, template: string): SafetyTranscript;
|
|
1800
|
+
/**
|
|
1801
|
+
* Destroy a sandbox and clean up resources.
|
|
1802
|
+
*/
|
|
1803
|
+
declare function destroySandbox(sandbox: Sandbox): Promise<void>;
|
|
1804
|
+
|
|
1805
|
+
/**
|
|
1806
|
+
* Evidence Authenticity via TLSNotary / zkTLS (Beta)
|
|
1807
|
+
*
|
|
1808
|
+
* ⚠️ BETA: This module defines the interface for evidence authenticity
|
|
1809
|
+
* proofs. The TLSNotary integration is planned for Q3 2026 when the
|
|
1810
|
+
* tooling stabilizes. The interface is stable and forward-compatible.
|
|
1811
|
+
*
|
|
1812
|
+
* Problem: When an agent fetches external data (API calls, web scraping)
|
|
1813
|
+
* and submits it as evidence to an Acta receipt, there's currently no
|
|
1814
|
+
* proof the data is authentic. The agent could fabricate the response.
|
|
1815
|
+
*
|
|
1816
|
+
* Solution: TLSNotary (tlsnotary.org) enables an agent to prove it
|
|
1817
|
+
* fetched specific data from a specific server without revealing
|
|
1818
|
+
* session cookies or API keys. The TLS session is notarized by a
|
|
1819
|
+
* third-party verifier, producing a cryptographic proof of authenticity.
|
|
1820
|
+
*
|
|
1821
|
+
* This module defines:
|
|
1822
|
+
* 1. The EvidenceAttestation format (for embedding in receipts)
|
|
1823
|
+
* 2. The verification interface (for checking attestations)
|
|
1824
|
+
* 3. Placeholder implementations that will be replaced with
|
|
1825
|
+
* real TLSNotary integration when the SDK matures
|
|
1826
|
+
*
|
|
1827
|
+
* Usage:
|
|
1828
|
+
* import { createEvidenceAttestation, verifyEvidenceAttestation } from './evidence-authenticity.js';
|
|
1829
|
+
*
|
|
1830
|
+
* // Create an attestation for data fetched from an API
|
|
1831
|
+
* const attestation = await createEvidenceAttestation({
|
|
1832
|
+
* url: 'https://api.example.com/data',
|
|
1833
|
+
* responseHash: sha256(responseBody),
|
|
1834
|
+
* method: 'GET',
|
|
1835
|
+
* timestamp: new Date().toISOString(),
|
|
1836
|
+
* });
|
|
1837
|
+
*
|
|
1838
|
+
* // Embed in receipt
|
|
1839
|
+
* receipt.evidence_attestation = attestation;
|
|
1840
|
+
*
|
|
1841
|
+
* // Verify
|
|
1842
|
+
* const valid = await verifyEvidenceAttestation(attestation);
|
|
1843
|
+
*/
|
|
1844
|
+
/**
|
|
1845
|
+
* Evidence attestation format — embedded in receipts to prove
|
|
1846
|
+
* the authenticity of externally fetched data.
|
|
1847
|
+
*/
|
|
1848
|
+
interface EvidenceAttestation {
|
|
1849
|
+
/** Version of the attestation format */
|
|
1850
|
+
version: '0.1-beta';
|
|
1851
|
+
/** Attestation method */
|
|
1852
|
+
method: 'self-reported' | 'tlsnotary' | 'oracle' | 'witness';
|
|
1853
|
+
/** URL that was fetched */
|
|
1854
|
+
url: string;
|
|
1855
|
+
/** HTTP method used */
|
|
1856
|
+
httpMethod: 'GET' | 'POST' | 'PUT' | 'DELETE';
|
|
1857
|
+
/** SHA-256 hash of the response body */
|
|
1858
|
+
responseHash: string;
|
|
1859
|
+
/** Response status code */
|
|
1860
|
+
statusCode: number;
|
|
1861
|
+
/** TLS server certificate fingerprint (SHA-256 of DER) */
|
|
1862
|
+
serverCertFingerprint?: string;
|
|
1863
|
+
/** Timestamp of the fetch */
|
|
1864
|
+
fetchedAt: string;
|
|
1865
|
+
/** Notary public key (for TLSNotary attestations) */
|
|
1866
|
+
notaryPublicKey?: string;
|
|
1867
|
+
/** Notary signature over the attestation */
|
|
1868
|
+
notarySignature?: string;
|
|
1869
|
+
/** Whether this attestation has been cryptographically verified */
|
|
1870
|
+
verified: boolean;
|
|
1871
|
+
/** Verification details */
|
|
1872
|
+
verificationNote: string;
|
|
1873
|
+
}
|
|
1874
|
+
/**
|
|
1875
|
+
* Input for creating an evidence attestation.
|
|
1876
|
+
*/
|
|
1877
|
+
interface EvidenceAttestationInput {
|
|
1878
|
+
/** URL that was fetched */
|
|
1879
|
+
url: string;
|
|
1880
|
+
/** HTTP method */
|
|
1881
|
+
httpMethod?: 'GET' | 'POST' | 'PUT' | 'DELETE';
|
|
1882
|
+
/** SHA-256 hash of the response body */
|
|
1883
|
+
responseHash: string;
|
|
1884
|
+
/** Response status code */
|
|
1885
|
+
statusCode?: number;
|
|
1886
|
+
/** Timestamp */
|
|
1887
|
+
timestamp?: string;
|
|
1888
|
+
}
|
|
1889
|
+
/**
|
|
1890
|
+
* Create an evidence attestation for externally fetched data.
|
|
1891
|
+
*
|
|
1892
|
+
* Current implementation: self-reported (the agent declares what it
|
|
1893
|
+
* fetched, but there's no third-party proof). This is clearly marked
|
|
1894
|
+
* as `method: 'self-reported'` in the attestation.
|
|
1895
|
+
*
|
|
1896
|
+
* Future: When TLSNotary SDK matures, this will produce
|
|
1897
|
+
* `method: 'tlsnotary'` attestations with cryptographic proofs.
|
|
1898
|
+
*
|
|
1899
|
+
* @param input - Details of the fetch to attest
|
|
1900
|
+
* @returns EvidenceAttestation for embedding in a receipt
|
|
1901
|
+
*
|
|
1902
|
+
* @patent Patent-protected construction — evidence authenticity attestation with
|
|
1903
|
+
* TLSNotary/zkTLS integration. Covered by Apache 2.0 patent grant for users of
|
|
1904
|
+
* this code. Clean-room reimplementation requires a patent license.
|
|
1905
|
+
* @see {@link https://datatracker.ietf.org/doc/draft-farley-acta-signed-receipts/}
|
|
1906
|
+
*/
|
|
1907
|
+
declare function createEvidenceAttestation(input: EvidenceAttestationInput): Promise<EvidenceAttestation>;
|
|
1908
|
+
/**
|
|
1909
|
+
* Verify an evidence attestation.
|
|
1910
|
+
*
|
|
1911
|
+
* For self-reported attestations, this always returns { valid: false }
|
|
1912
|
+
* with a note explaining that self-reported data cannot be verified.
|
|
1913
|
+
*
|
|
1914
|
+
* For TLSNotary attestations, this will verify the notary's signature
|
|
1915
|
+
* over the TLS session transcript.
|
|
1916
|
+
*
|
|
1917
|
+
* @patent Patent-protected construction — evidence authenticity attestation with
|
|
1918
|
+
* TLSNotary/zkTLS integration. Covered by Apache 2.0 patent grant for users of
|
|
1919
|
+
* this code. Clean-room reimplementation requires a patent license.
|
|
1920
|
+
* @see {@link https://datatracker.ietf.org/doc/draft-farley-acta-signed-receipts/}
|
|
1921
|
+
*/
|
|
1922
|
+
declare function verifyEvidenceAttestation(attestation: EvidenceAttestation): Promise<{
|
|
1923
|
+
valid: boolean;
|
|
1924
|
+
method: string;
|
|
1925
|
+
note: string;
|
|
1926
|
+
}>;
|
|
1927
|
+
/**
|
|
1928
|
+
* Hash a response body for attestation.
|
|
1929
|
+
* Uses SHA-256 for consistency with the rest of the receipt format.
|
|
1930
|
+
*/
|
|
1931
|
+
declare function hashResponseBody(body: string | Buffer): string;
|
|
1932
|
+
/**
|
|
1933
|
+
* Create an attestation field for embedding in a receipt payload.
|
|
1934
|
+
* This is the format that goes into the `evidence_attestation`
|
|
1935
|
+
* field of an Acta receipt.
|
|
1936
|
+
*
|
|
1937
|
+
* @patent Patent-protected construction — evidence authenticity attestation with
|
|
1938
|
+
* TLSNotary/zkTLS integration. Covered by Apache 2.0 patent grant for users of
|
|
1939
|
+
* this code. Clean-room reimplementation requires a patent license.
|
|
1940
|
+
* @see {@link https://datatracker.ietf.org/doc/draft-farley-acta-signed-receipts/}
|
|
1941
|
+
*/
|
|
1942
|
+
declare function createAttestationField(attestation: EvidenceAttestation): {
|
|
1943
|
+
evidence_authenticity: {
|
|
1944
|
+
version: string;
|
|
1945
|
+
method: string;
|
|
1946
|
+
url_hash: string;
|
|
1947
|
+
response_hash: string;
|
|
1948
|
+
fetched_at: string;
|
|
1949
|
+
verified: boolean;
|
|
1950
|
+
note: string;
|
|
1951
|
+
};
|
|
1952
|
+
};
|
|
1953
|
+
|
|
1954
|
+
/**
|
|
1955
|
+
* C2PA Content Credential Integration
|
|
1956
|
+
*
|
|
1957
|
+
* Embeds Veritas Acta provenance into C2PA (Coalition for Content
|
|
1958
|
+
* Provenance and Authenticity) manifest assertions. This enables
|
|
1959
|
+
* the "right-click to verify" UX — any content generated during
|
|
1960
|
+
* a governed agent session carries its Acta receipt chain as a
|
|
1961
|
+
* Content Credential.
|
|
1962
|
+
*
|
|
1963
|
+
* C2PA is backed by Adobe, Microsoft, BBC, and others. By embedding
|
|
1964
|
+
* Acta receipts as C2PA assertions, AI-generated content becomes
|
|
1965
|
+
* traceable through the existing content provenance ecosystem.
|
|
1966
|
+
*
|
|
1967
|
+
* Usage:
|
|
1968
|
+
* import { createC2PAManifest, embedInImage, embedInDocument } from './c2pa-credentials.js';
|
|
1969
|
+
*
|
|
1970
|
+
* // Create a C2PA manifest from an Acta receipt chain
|
|
1971
|
+
* const manifest = createC2PAManifest(receipts, {
|
|
1972
|
+
* title: 'AI-generated report',
|
|
1973
|
+
* generator: 'protect-mcp v0.3.3',
|
|
1974
|
+
* });
|
|
1975
|
+
*
|
|
1976
|
+
* // The manifest can be embedded in images, PDFs, or documents
|
|
1977
|
+
* // using c2patool or the C2PA Rust/JS SDK
|
|
1978
|
+
*/
|
|
1979
|
+
/**
|
|
1980
|
+
* C2PA Manifest structure compatible with the C2PA specification.
|
|
1981
|
+
* This is the JSON representation that c2patool can consume.
|
|
1982
|
+
*/
|
|
1983
|
+
interface C2PAManifest {
|
|
1984
|
+
/** C2PA claim generator identifier */
|
|
1985
|
+
claim_generator: string;
|
|
1986
|
+
/** C2PA claim generator version */
|
|
1987
|
+
claim_generator_info: Array<{
|
|
1988
|
+
name: string;
|
|
1989
|
+
version: string;
|
|
1990
|
+
icon?: {
|
|
1991
|
+
format: string;
|
|
1992
|
+
identifier: string;
|
|
1993
|
+
};
|
|
1994
|
+
}>;
|
|
1995
|
+
/** Title of the content */
|
|
1996
|
+
title: string;
|
|
1997
|
+
/** Assertions about the content */
|
|
1998
|
+
assertions: C2PAAssertion[];
|
|
1999
|
+
/** Ingredients (source materials) */
|
|
2000
|
+
ingredients?: C2PAIngredient[];
|
|
2001
|
+
}
|
|
2002
|
+
interface C2PAAssertion {
|
|
2003
|
+
/** Assertion label (URI) */
|
|
2004
|
+
label: string;
|
|
2005
|
+
/** Assertion data */
|
|
2006
|
+
data: Record<string, unknown>;
|
|
2007
|
+
/** Whether this assertion is hashed (for privacy) */
|
|
2008
|
+
is_hash?: boolean;
|
|
2009
|
+
}
|
|
2010
|
+
interface C2PAIngredient {
|
|
2011
|
+
/** Title of the ingredient */
|
|
2012
|
+
title: string;
|
|
2013
|
+
/** Relationship to the output */
|
|
2014
|
+
relationship: 'parentOf' | 'componentOf' | 'inputTo';
|
|
2015
|
+
/** Hash of the ingredient */
|
|
2016
|
+
hash?: string;
|
|
2017
|
+
}
|
|
2018
|
+
interface C2PAOptions {
|
|
2019
|
+
/** Title of the generated content */
|
|
2020
|
+
title: string;
|
|
2021
|
+
/** Generator name (default: 'protect-mcp') */
|
|
2022
|
+
generator?: string;
|
|
2023
|
+
/** Generator version */
|
|
2024
|
+
version?: string;
|
|
2025
|
+
/** Whether to include full receipt data or only hashes */
|
|
2026
|
+
includeFullReceipts?: boolean;
|
|
2027
|
+
/** Additional assertions to include */
|
|
2028
|
+
additionalAssertions?: C2PAAssertion[];
|
|
2029
|
+
}
|
|
2030
|
+
/**
|
|
2031
|
+
* Create a C2PA manifest from an Acta receipt chain.
|
|
2032
|
+
*
|
|
2033
|
+
* The manifest contains:
|
|
2034
|
+
* - An `acta.decision-provenance` assertion with the receipt chain summary
|
|
2035
|
+
* - An `acta.policy-compliance` assertion showing policy adherence
|
|
2036
|
+
* - Standard C2PA actions (c2pa.actions) documenting what the agent did
|
|
2037
|
+
*
|
|
2038
|
+
* @param receipts - Array of Acta receipts from the agent session
|
|
2039
|
+
* @param options - Configuration for the manifest
|
|
2040
|
+
* @returns C2PA manifest JSON (compatible with c2patool)
|
|
2041
|
+
*/
|
|
2042
|
+
declare function createC2PAManifest(receipts: Array<Record<string, unknown>>, options: C2PAOptions): C2PAManifest;
|
|
2043
|
+
/**
|
|
2044
|
+
* Export the C2PA manifest as JSON for use with c2patool.
|
|
2045
|
+
*
|
|
2046
|
+
* Usage:
|
|
2047
|
+
* const json = exportC2PAManifestJSON(manifest);
|
|
2048
|
+
* fs.writeFileSync('manifest.json', json);
|
|
2049
|
+
* // Then: c2patool output.jpg -m manifest.json -o signed-output.jpg
|
|
2050
|
+
*/
|
|
2051
|
+
declare function exportC2PAManifestJSON(manifest: C2PAManifest): string;
|
|
2052
|
+
/**
|
|
2053
|
+
* Generate a c2patool command for embedding the manifest into a file.
|
|
2054
|
+
*
|
|
2055
|
+
* @param manifestPath - Path to the manifest JSON file
|
|
2056
|
+
* @param inputPath - Path to the input file (image, PDF, etc.)
|
|
2057
|
+
* @param outputPath - Path for the signed output file
|
|
2058
|
+
* @returns The c2patool command to run
|
|
2059
|
+
*/
|
|
2060
|
+
declare function generateC2PACommand(manifestPath: string, inputPath: string, outputPath: string): string;
|
|
2061
|
+
/**
|
|
2062
|
+
* Verify that a file contains valid Acta C2PA assertions.
|
|
2063
|
+
*
|
|
2064
|
+
* @param c2paManifestJson - The C2PA manifest JSON extracted from a file
|
|
2065
|
+
* @returns Verification result
|
|
2066
|
+
*/
|
|
2067
|
+
declare function verifyActaC2PAAssertions(c2paManifestJson: string): {
|
|
2068
|
+
hasActaProvenance: boolean;
|
|
2069
|
+
receiptCount: number;
|
|
2070
|
+
merkleRoot: string | null;
|
|
2071
|
+
complianceRate: string | null;
|
|
2072
|
+
verifyUrl: string | null;
|
|
2073
|
+
};
|
|
2074
|
+
|
|
2075
|
+
/**
|
|
2076
|
+
* Prediction Lifecycle Bridge
|
|
2077
|
+
*
|
|
2078
|
+
* Bridges Veritas Acta prediction receipts to external forecasting
|
|
2079
|
+
* platforms (Metaculus, Manifold Markets) for calibration tracking.
|
|
2080
|
+
*
|
|
2081
|
+
* Status: Experimental
|
|
2082
|
+
*/
|
|
2083
|
+
interface PredictionReceipt {
|
|
2084
|
+
receipt_id: string;
|
|
2085
|
+
receipt_type: 'prediction';
|
|
2086
|
+
issuer_id: string;
|
|
2087
|
+
event_time: string;
|
|
2088
|
+
payload: {
|
|
2089
|
+
claim: string;
|
|
2090
|
+
probability: number;
|
|
2091
|
+
resolution_criteria: string;
|
|
2092
|
+
resolution_deadline: string;
|
|
2093
|
+
domain?: string;
|
|
2094
|
+
tags?: string[];
|
|
2095
|
+
};
|
|
2096
|
+
signature: string;
|
|
2097
|
+
}
|
|
2098
|
+
interface PredictionResolution {
|
|
2099
|
+
receipt_id: string;
|
|
2100
|
+
receipt_type: 'resolution';
|
|
2101
|
+
parent_receipts: string[];
|
|
2102
|
+
payload: {
|
|
2103
|
+
resolved: boolean;
|
|
2104
|
+
resolution_value: 'true' | 'false' | 'ambiguous';
|
|
2105
|
+
resolution_source: string;
|
|
2106
|
+
resolution_time: string;
|
|
2107
|
+
};
|
|
2108
|
+
signature: string;
|
|
2109
|
+
}
|
|
2110
|
+
interface CalibrationScore {
|
|
2111
|
+
total_predictions: number;
|
|
2112
|
+
resolved: number;
|
|
2113
|
+
brier_score: number;
|
|
2114
|
+
calibration_buckets: Array<{
|
|
2115
|
+
bucket: string;
|
|
2116
|
+
predicted_probability: number;
|
|
2117
|
+
actual_frequency: number;
|
|
2118
|
+
count: number;
|
|
2119
|
+
}>;
|
|
2120
|
+
}
|
|
2121
|
+
/**
|
|
2122
|
+
* Compute Brier score from a set of predictions and their resolutions
|
|
2123
|
+
*/
|
|
2124
|
+
declare function computeCalibration(predictions: PredictionReceipt[], resolutions: Map<string, PredictionResolution>): CalibrationScore;
|
|
2125
|
+
/**
|
|
2126
|
+
* Format prediction for Metaculus API submission (placeholder)
|
|
2127
|
+
*/
|
|
2128
|
+
declare function toMetaculusFormat(prediction: PredictionReceipt): {
|
|
2129
|
+
question_url?: string;
|
|
2130
|
+
prediction_value: number;
|
|
2131
|
+
acta_receipt_id: string;
|
|
2132
|
+
acta_signature: string;
|
|
2133
|
+
};
|
|
2134
|
+
/**
|
|
2135
|
+
* Format prediction for Manifold Markets API submission (placeholder)
|
|
2136
|
+
*/
|
|
2137
|
+
declare function toManifoldFormat(prediction: PredictionReceipt): {
|
|
2138
|
+
probability: number;
|
|
2139
|
+
acta_receipt_id: string;
|
|
2140
|
+
acta_signature: string;
|
|
2141
|
+
};
|
|
2142
|
+
|
|
2143
|
+
/**
|
|
2144
|
+
* Agent-to-Agent Receipt Exchange
|
|
2145
|
+
*
|
|
2146
|
+
* Middleware for multi-agent systems (CrewAI, LangGraph, AutoGen) that
|
|
2147
|
+
* propagates receipts across agent boundaries. Each hop produces a
|
|
2148
|
+
* chained receipt, enabling end-to-end accountability tracing.
|
|
2149
|
+
*
|
|
2150
|
+
* Status: Beta — API may change
|
|
2151
|
+
*
|
|
2152
|
+
* @example
|
|
2153
|
+
* ```typescript
|
|
2154
|
+
* import { ReceiptPropagator } from 'protect-mcp/agent-exchange';
|
|
2155
|
+
*
|
|
2156
|
+
* const propagator = new ReceiptPropagator({ issuer: 'agent-alpha' });
|
|
2157
|
+
*
|
|
2158
|
+
* // Agent A delegates to Agent B
|
|
2159
|
+
* const delegation = propagator.delegate('agent-beta', {
|
|
2160
|
+
* tools: ['read_file', 'search_web'],
|
|
2161
|
+
* scope: 'task-123',
|
|
2162
|
+
* ttl: 3600,
|
|
2163
|
+
* });
|
|
2164
|
+
*
|
|
2165
|
+
* // Agent B receives the delegation and wraps its actions
|
|
2166
|
+
* const action = propagator.wrapAction('read_file', {
|
|
2167
|
+
* delegation_receipt: delegation.receipt_id,
|
|
2168
|
+
* args: { path: 'data.json' },
|
|
2169
|
+
* });
|
|
2170
|
+
*
|
|
2171
|
+
* // Verify the full chain
|
|
2172
|
+
* const chain = propagator.traceChain(action.receipt_id);
|
|
2173
|
+
* // Returns: [delegation_receipt, action_receipt]
|
|
2174
|
+
* ```
|
|
2175
|
+
*/
|
|
2176
|
+
interface DelegationReceipt {
|
|
2177
|
+
receipt_id: string;
|
|
2178
|
+
receipt_type: 'delegation';
|
|
2179
|
+
issuer_id: string;
|
|
2180
|
+
event_time: string;
|
|
2181
|
+
payload: {
|
|
2182
|
+
/** The agent receiving delegated authority */
|
|
2183
|
+
delegate_id: string;
|
|
2184
|
+
/** Tools the delegate is authorized to use */
|
|
2185
|
+
authorized_tools: string[];
|
|
2186
|
+
/** Scope identifier for this delegation */
|
|
2187
|
+
scope: string;
|
|
2188
|
+
/** Time-to-live in seconds */
|
|
2189
|
+
ttl: number;
|
|
2190
|
+
/** Expiry timestamp */
|
|
2191
|
+
expires_at: string;
|
|
2192
|
+
/** Maximum number of tool calls allowed */
|
|
2193
|
+
max_calls?: number;
|
|
2194
|
+
/** Whether the delegate can further sub-delegate */
|
|
2195
|
+
allow_subdelegation: boolean;
|
|
2196
|
+
};
|
|
2197
|
+
parent_receipts: string[];
|
|
2198
|
+
signature?: string;
|
|
2199
|
+
}
|
|
2200
|
+
interface ActionReceipt {
|
|
2201
|
+
receipt_id: string;
|
|
2202
|
+
receipt_type: 'execution';
|
|
2203
|
+
issuer_id: string;
|
|
2204
|
+
event_time: string;
|
|
2205
|
+
payload: {
|
|
2206
|
+
tool_name: string;
|
|
2207
|
+
decision: 'allow' | 'deny';
|
|
2208
|
+
delegation_receipt: string;
|
|
2209
|
+
scope: string;
|
|
2210
|
+
call_index: number;
|
|
2211
|
+
};
|
|
2212
|
+
parent_receipts: string[];
|
|
2213
|
+
signature?: string;
|
|
2214
|
+
}
|
|
2215
|
+
interface PropagatorConfig {
|
|
2216
|
+
/** Issuer ID for this agent */
|
|
2217
|
+
issuer: string;
|
|
2218
|
+
/** Optional signing function (receipt → signed receipt) */
|
|
2219
|
+
signer?: (receipt: Record<string, unknown>) => Record<string, unknown>;
|
|
2220
|
+
}
|
|
2221
|
+
/**
|
|
2222
|
+
* Propagates receipts across agent boundaries in multi-agent systems.
|
|
2223
|
+
* Each hop produces a chained receipt enabling end-to-end accountability.
|
|
2224
|
+
*
|
|
2225
|
+
* @patent Patent-protected construction — delegated signing with receipt chain
|
|
2226
|
+
* propagation. Covered by Apache 2.0 patent grant for users of this code.
|
|
2227
|
+
* Clean-room reimplementation requires a patent license.
|
|
2228
|
+
* @see {@link https://datatracker.ietf.org/doc/draft-farley-acta-signed-receipts/}
|
|
2229
|
+
*/
|
|
2230
|
+
declare class ReceiptPropagator {
|
|
2231
|
+
private issuer;
|
|
2232
|
+
private signer?;
|
|
2233
|
+
private receipts;
|
|
2234
|
+
private delegationCallCounts;
|
|
2235
|
+
constructor(config: PropagatorConfig);
|
|
2236
|
+
/**
|
|
2237
|
+
* Create a delegation receipt authorizing another agent to use specific tools.
|
|
2238
|
+
*
|
|
2239
|
+
* @patent Patent-protected construction — delegated signing with receipt chain
|
|
2240
|
+
* propagation. Covered by Apache 2.0 patent grant for users of this code.
|
|
2241
|
+
* Clean-room reimplementation requires a patent license.
|
|
2242
|
+
* @see {@link https://datatracker.ietf.org/doc/draft-farley-acta-signed-receipts/}
|
|
2243
|
+
*/
|
|
2244
|
+
delegate(delegateId: string, options: {
|
|
2245
|
+
tools: string[];
|
|
2246
|
+
scope: string;
|
|
2247
|
+
ttl: number;
|
|
2248
|
+
maxCalls?: number;
|
|
2249
|
+
allowSubdelegation?: boolean;
|
|
2250
|
+
parentReceipts?: string[];
|
|
2251
|
+
}): DelegationReceipt;
|
|
2252
|
+
/**
|
|
2253
|
+
* Wrap a tool call with a receipt that references the delegation.
|
|
2254
|
+
* Validates the delegation is still valid (not expired, within call limit,
|
|
2255
|
+
* tool is authorized).
|
|
2256
|
+
*
|
|
2257
|
+
* @patent Patent-protected construction — delegated signing with receipt chain
|
|
2258
|
+
* propagation. Covered by Apache 2.0 patent grant for users of this code.
|
|
2259
|
+
* Clean-room reimplementation requires a patent license.
|
|
2260
|
+
* @see {@link https://datatracker.ietf.org/doc/draft-farley-acta-signed-receipts/}
|
|
2261
|
+
*/
|
|
2262
|
+
wrapAction(toolName: string, options: {
|
|
2263
|
+
delegation_receipt: string;
|
|
2264
|
+
args?: Record<string, unknown>;
|
|
2265
|
+
}): ActionReceipt;
|
|
2266
|
+
/**
|
|
2267
|
+
* Trace the full receipt chain from a given receipt back to the root delegation.
|
|
2268
|
+
*
|
|
2269
|
+
* @patent Patent-protected construction — delegated signing with receipt chain
|
|
2270
|
+
* propagation. Covered by Apache 2.0 patent grant for users of this code.
|
|
2271
|
+
* Clean-room reimplementation requires a patent license.
|
|
2272
|
+
* @see {@link https://datatracker.ietf.org/doc/draft-farley-acta-signed-receipts/}
|
|
2273
|
+
*/
|
|
2274
|
+
traceChain(receiptId: string): Array<DelegationReceipt | ActionReceipt>;
|
|
2275
|
+
/**
|
|
2276
|
+
* Export all receipts as a JSON array (for verification, archival, or Trace visualization).
|
|
2277
|
+
*/
|
|
2278
|
+
exportAll(): Array<DelegationReceipt | ActionReceipt>;
|
|
2279
|
+
/**
|
|
2280
|
+
* Validate that a delegation chain is intact and all signatures verify.
|
|
2281
|
+
*
|
|
2282
|
+
* @patent Patent-protected construction — delegated signing with receipt chain
|
|
2283
|
+
* propagation. Covered by Apache 2.0 patent grant for users of this code.
|
|
2284
|
+
* Clean-room reimplementation requires a patent license.
|
|
2285
|
+
* @see {@link https://datatracker.ietf.org/doc/draft-farley-acta-signed-receipts/}
|
|
2286
|
+
*/
|
|
2287
|
+
validateChain(receiptId: string): {
|
|
2288
|
+
valid: boolean;
|
|
2289
|
+
chain_length: number;
|
|
2290
|
+
issues: string[];
|
|
2291
|
+
};
|
|
2292
|
+
}
|
|
2293
|
+
/**
|
|
2294
|
+
* Create a LangGraph-compatible state channel that propagates receipts.
|
|
2295
|
+
*
|
|
2296
|
+
* Usage with LangGraph:
|
|
2297
|
+
* ```typescript
|
|
2298
|
+
* import { createReceiptChannel } from 'protect-mcp/agent-exchange';
|
|
2299
|
+
*
|
|
2300
|
+
* const channel = createReceiptChannel('orchestrator');
|
|
2301
|
+
*
|
|
2302
|
+
* // In your LangGraph node:
|
|
2303
|
+
* const result = await channel.withDelegation('worker-agent', ['read_file'], async (ctx) => {
|
|
2304
|
+
* // ctx.delegation is the delegation receipt
|
|
2305
|
+
* // Agent B's actions will reference this delegation
|
|
2306
|
+
* return await agentB.run(ctx.delegation);
|
|
2307
|
+
* });
|
|
2308
|
+
* ```
|
|
2309
|
+
*/
|
|
2310
|
+
declare function createReceiptChannel(orchestratorId: string): {
|
|
2311
|
+
propagator: ReceiptPropagator;
|
|
2312
|
+
withDelegation<T>(delegateId: string, tools: string[], fn: (ctx: {
|
|
2313
|
+
delegation: DelegationReceipt;
|
|
2314
|
+
propagator: ReceiptPropagator;
|
|
2315
|
+
}) => Promise<T>, options?: {
|
|
2316
|
+
ttl?: number;
|
|
2317
|
+
maxCalls?: number;
|
|
2318
|
+
scope?: string;
|
|
2319
|
+
}): Promise<{
|
|
2320
|
+
result: T;
|
|
2321
|
+
delegation: DelegationReceipt;
|
|
2322
|
+
chain: Array<DelegationReceipt | ActionReceipt>;
|
|
2323
|
+
}>;
|
|
2324
|
+
};
|
|
2325
|
+
|
|
2326
|
+
/**
|
|
2327
|
+
* Confidential Computing Interface
|
|
2328
|
+
*
|
|
2329
|
+
* Defines the interface for TEE (Trusted Execution Environment) attestation
|
|
2330
|
+
* and confidential inference integration. When enabled, agents must prove
|
|
2331
|
+
* they generated their keys inside a secure enclave and their code hasn't
|
|
2332
|
+
* been tampered with before receiving elevated trust tiers.
|
|
2333
|
+
*
|
|
2334
|
+
* Status: Beta — Enterprise feature
|
|
2335
|
+
*
|
|
2336
|
+
* Supported attestation providers:
|
|
2337
|
+
* - AWS Nitro Enclaves (via attestation documents)
|
|
2338
|
+
* - Intel TDX (via DCAP quotes)
|
|
2339
|
+
* - AMD SEV-SNP (via attestation reports)
|
|
2340
|
+
* - Generic COSE-signed attestations
|
|
2341
|
+
*
|
|
2342
|
+
* @example
|
|
2343
|
+
* ```typescript
|
|
2344
|
+
* import { ConfidentialGate, verifyAttestation } from 'protect-mcp/confidential';
|
|
2345
|
+
*
|
|
2346
|
+
* const gate = new ConfidentialGate({
|
|
2347
|
+
* require_attestation: true,
|
|
2348
|
+
* accepted_providers: ['nitro', 'tdx'],
|
|
2349
|
+
* min_trust_tier: 'evidenced',
|
|
2350
|
+
* });
|
|
2351
|
+
*
|
|
2352
|
+
* // Agent presents attestation during handshake
|
|
2353
|
+
* const result = gate.evaluateAttestation(attestationDoc);
|
|
2354
|
+
* // result: { accepted: true, tier: 'privileged', provider: 'nitro' }
|
|
2355
|
+
* ```
|
|
2356
|
+
*/
|
|
2357
|
+
type AttestationProvider = 'nitro' | 'tdx' | 'sev_snp' | 'generic';
|
|
2358
|
+
interface AttestationDocument {
|
|
2359
|
+
/** The attestation provider */
|
|
2360
|
+
provider: AttestationProvider;
|
|
2361
|
+
/** Raw attestation bytes (base64-encoded) */
|
|
2362
|
+
attestation: string;
|
|
2363
|
+
/** Public key generated inside the enclave */
|
|
2364
|
+
enclave_public_key: string;
|
|
2365
|
+
/** Measurements / PCR values */
|
|
2366
|
+
measurements: Record<string, string>;
|
|
2367
|
+
/** Timestamp of attestation */
|
|
2368
|
+
timestamp: string;
|
|
2369
|
+
/** Optional: Nonce used for freshness */
|
|
2370
|
+
nonce?: string;
|
|
2371
|
+
}
|
|
2372
|
+
interface AttestationResult {
|
|
2373
|
+
/** Whether the attestation was accepted */
|
|
2374
|
+
accepted: boolean;
|
|
2375
|
+
/** Resulting trust tier */
|
|
2376
|
+
tier: 'unknown' | 'signed' | 'evidenced' | 'privileged';
|
|
2377
|
+
/** Provider that issued the attestation */
|
|
2378
|
+
provider: AttestationProvider;
|
|
2379
|
+
/** Reason for acceptance or rejection */
|
|
2380
|
+
reason: string;
|
|
2381
|
+
/** Receipt documenting the attestation evaluation */
|
|
2382
|
+
receipt_id?: string;
|
|
2383
|
+
}
|
|
2384
|
+
interface ConfidentialGateConfig {
|
|
2385
|
+
/** Require attestation for elevated trust tiers */
|
|
2386
|
+
require_attestation: boolean;
|
|
2387
|
+
/** Accepted attestation providers */
|
|
2388
|
+
accepted_providers: AttestationProvider[];
|
|
2389
|
+
/** Minimum trust tier that requires attestation */
|
|
2390
|
+
min_trust_tier: 'signed' | 'evidenced' | 'privileged';
|
|
2391
|
+
/** Expected measurement values (PCRs) for validation */
|
|
2392
|
+
expected_measurements?: Record<string, string>;
|
|
2393
|
+
/** Maximum age of attestation document (seconds) */
|
|
2394
|
+
max_attestation_age?: number;
|
|
2395
|
+
}
|
|
2396
|
+
declare class ConfidentialGate {
|
|
2397
|
+
private config;
|
|
2398
|
+
constructor(config: ConfidentialGateConfig);
|
|
2399
|
+
/**
|
|
2400
|
+
* Evaluate an attestation document and determine the resulting trust tier.
|
|
2401
|
+
*/
|
|
2402
|
+
evaluateAttestation(doc: AttestationDocument): AttestationResult;
|
|
2403
|
+
/**
|
|
2404
|
+
* Check if an agent's current tier requires attestation.
|
|
2405
|
+
*/
|
|
2406
|
+
requiresAttestation(currentTier: string): boolean;
|
|
2407
|
+
/**
|
|
2408
|
+
* Generate an attestation receipt documenting the evaluation.
|
|
2409
|
+
*/
|
|
2410
|
+
toReceipt(result: AttestationResult, agentId: string): Record<string, unknown>;
|
|
2411
|
+
}
|
|
2412
|
+
/**
|
|
2413
|
+
* Configuration for confidential model inference.
|
|
2414
|
+
* Wraps model API calls to ensure data privacy during evaluation.
|
|
2415
|
+
*/
|
|
2416
|
+
interface ConfidentialInferenceConfig {
|
|
2417
|
+
/** Provider for confidential inference */
|
|
2418
|
+
provider: 'local_tee' | 'homomorphic' | 'secure_enclave';
|
|
2419
|
+
/** Whether to encrypt prompts before sending to the model */
|
|
2420
|
+
encrypt_prompts: boolean;
|
|
2421
|
+
/** Whether to verify model outputs came from the expected enclave */
|
|
2422
|
+
verify_outputs: boolean;
|
|
2423
|
+
/** Homomorphic encryption key (for 'homomorphic' provider) */
|
|
2424
|
+
he_public_key?: string;
|
|
2425
|
+
}
|
|
2426
|
+
/**
|
|
2427
|
+
* Wraps a model inference call with confidential computing guarantees.
|
|
2428
|
+
*
|
|
2429
|
+
* In 'local_tee' mode: The model runs inside a TEE and provides attestation
|
|
2430
|
+
* that the inference was performed correctly.
|
|
2431
|
+
*
|
|
2432
|
+
* In 'homomorphic' mode: Prompts are encrypted client-side and the model
|
|
2433
|
+
* operates on ciphertext (using Zama Concrete ML or similar).
|
|
2434
|
+
*
|
|
2435
|
+
* In 'secure_enclave' mode: Uses NVIDIA Confidential Computing or similar
|
|
2436
|
+
* hardware to ensure the model cannot see plaintext data.
|
|
2437
|
+
*
|
|
2438
|
+
* Status: Interface only — implementation requires specific TEE/HE SDK integration
|
|
2439
|
+
*/
|
|
2440
|
+
declare function confidentialInference(_prompt: string, _config: ConfidentialInferenceConfig): Promise<{
|
|
2441
|
+
response: string;
|
|
2442
|
+
attestation?: AttestationDocument;
|
|
2443
|
+
encrypted: boolean;
|
|
2444
|
+
receipt: Record<string, unknown>;
|
|
2445
|
+
}>;
|
|
2446
|
+
|
|
2447
|
+
export { type ActionReceipt, type AdmissionResult, type AgentId, type AgentManifest, type ApprovalAssertion, type ApprovalChallenge, type ApprovalNotification, type ApprovalResult, type ArenaPayload, type ArenaReceipt, type AttestationDocument, type AttestationPayload, type AttestationProvider, type AttestationReceipt, type AttestationResult, type AuditBundle, type AuditBundleOptions, type BenchmarkPayload, type BenchmarkReceipt, type BuilderId, type C2PAAssertion, type C2PAIngredient, type C2PAManifest, type C2PAOptions, type CalibrationScore, type ComplianceReport, ConfidentialGate, type ConfidentialGateConfig, type ConfidentialInferenceConfig, type CredentialConfig, type DecisionContext, type DecisionLog, type DelegationReceipt, type DisclosureMode, type Ed25519PublicKey, type EvidenceAttestation, type EvidenceAttestationInput, type EvidenceIssuer, type EvidenceReceipt, type EvidenceReceiptBase, type EvidenceSummary, type EvidenceSummaryEntry, type EvidenceType, type ExternalDecision, type ExternalPDPConfig, type HFDatasetMetadata, type HFReceiptRow, type IssuerType, type JsonRpcRequest, type JsonRpcResponse, type LeaseCompatibility, type ManifestBuilder, type ManifestCapabilities, type ManifestConfig, type ManifestIdentity, type ManifestPresentation, type ManifestSignature, type ManifestStatus, type NotificationConfig, type PolicyEngineMode, type PredictionReceipt, type PredictionResolution, type PropagatorConfig, type ProtectConfig, ProtectGateway, type ProtectPolicy, type RateLimit, ReceiptPropagator, type RedactedResult, type RedactionSalt, type RekorAnchor, type RekorVerification, type RestraintPayload, type RestraintReceipt, type SHA256Hash, type SafetyTranscript, type Sandbox, type SandboxConfig, type SandboxReceipt, type SandboxResult, type SandboxToolCall, type SigningConfig, type SimulationResult, type SimulationSummary, type TierOverrides, type ToolPolicy, type TrustTier, type WorkPayload, type WorkReceipt, anchorToRekor, buildDecisionContext, checkRateLimit, collectSignedReceipts, computeCalibration, confidentialInference, createApprovalChallenge, createApprovalReceiptPayload, createAttestationField, createAuditBundle, createC2PAManifest, createDisclosurePackage, createEvidenceAttestation, createLogAnchorField, createReceiptChannel, createSandbox, destroySandbox, ed25519ToDIDKey, evaluateTier, exportC2PAManifestJSON, exportJSONL, formatReportMarkdown, formatSimulation, generateC2PACommand, generateDatasetCard, generateHFMetadata, generateReport, generateSafetyTranscript, getSignerInfo, getToolPolicy, hashReceipt, hashResponseBody, initSigning, isAgentId, isDisclosureMode, isEvidenceType, isManifestStatus, isSigningEnabled, listCredentialLabels, loadPolicy, manifestToVC, meetsMinTier, parseLogFile, parseNotificationConfigFromEnv, parseRateLimit, queryExternalPDP, receiptToVP, receiptsToHFRows, redactFields, resolveCredential, revealField, runInSandbox, sendApprovalNotification, signDecision, simulate, toCredentialRequestOptions, toManifoldFormat, toMetaculusFormat, validateCredentials, validateEvidenceReceipt, validateManifest, verifyActaC2PAAssertions, verifyAllCommitments, verifyApprovalAssertion, verifyCommitment, verifyEvidenceAttestation, verifyRekorAnchor };
|