@nexart/mcp-server 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +53 -0
- package/CONTRIBUTING.md +56 -0
- package/LICENSE +202 -0
- package/NOTICE +14 -0
- package/README.md +340 -2
- package/SECURITY.md +76 -0
- package/THIRD_PARTY_NOTICES.md +111 -0
- package/dist/adapters.d.ts +16 -0
- package/dist/adapters.js +48 -0
- package/dist/approve-public.d.ts +2 -0
- package/dist/approve-public.js +65 -0
- package/dist/contracts.d.ts +48 -0
- package/dist/contracts.js +34 -0
- package/dist/create-confidential.d.ts +2 -0
- package/dist/create-confidential.js +34 -0
- package/dist/instrumentation/openai-worker.d.ts +1 -0
- package/dist/instrumentation/openai-worker.js +26 -0
- package/dist/instrumentation/openai.d.ts +51 -0
- package/dist/instrumentation/openai.js +197 -0
- package/dist/limits.d.ts +15 -0
- package/dist/limits.js +62 -0
- package/dist/lookup/contracts.d.ts +38 -0
- package/dist/lookup/contracts.js +22 -0
- package/dist/lookup/verify.d.ts +54 -0
- package/dist/lookup/verify.js +110 -0
- package/dist/network/client.d.ts +26 -0
- package/dist/network/client.js +188 -0
- package/dist/network/contracts.d.ts +104 -0
- package/dist/network/contracts.js +54 -0
- package/dist/network-tools.d.ts +5 -0
- package/dist/network-tools.js +32 -0
- package/dist/owner/create.d.ts +52 -0
- package/dist/owner/create.js +117 -0
- package/dist/owner/custody.d.ts +33 -0
- package/dist/owner/custody.js +200 -0
- package/dist/owner/host.d.ts +10 -0
- package/dist/owner/host.js +70 -0
- package/dist/owner/publisher.d.ts +21 -0
- package/dist/owner/publisher.js +27 -0
- package/dist/owner/reconcile.d.ts +16 -0
- package/dist/owner/reconcile.js +109 -0
- package/dist/receipts/contracts.d.ts +72 -0
- package/dist/receipts/contracts.js +33 -0
- package/dist/receipts/verify.d.ts +4 -0
- package/dist/receipts/verify.js +104 -0
- package/dist/record/contracts.d.ts +281 -0
- package/dist/record/contracts.js +70 -0
- package/dist/record/customer.d.ts +40 -0
- package/dist/record/customer.js +99 -0
- package/dist/record/policy.d.ts +46 -0
- package/dist/record/policy.js +67 -0
- package/dist/record/publication.d.ts +23 -0
- package/dist/record/publication.js +148 -0
- package/dist/record/record.d.ts +12 -0
- package/dist/record/record.js +93 -0
- package/dist/record/state.d.ts +44 -0
- package/dist/record/state.js +84 -0
- package/dist/record-tools.d.ts +10 -0
- package/dist/record-tools.js +85 -0
- package/dist/recover-confidential.d.ts +2 -0
- package/dist/recover-confidential.js +13 -0
- package/dist/results.d.ts +8 -0
- package/dist/results.js +83 -0
- package/dist/server.d.ts +2 -0
- package/dist/server.js +39 -0
- package/dist/stdio.d.ts +2 -0
- package/dist/stdio.js +104 -0
- package/dist/trust/lifecycle.d.ts +13 -0
- package/dist/trust/lifecycle.js +42 -0
- package/dist/trust/policy.d.ts +14 -0
- package/dist/trust/policy.js +6 -0
- package/dist/verify.d.ts +3 -0
- package/dist/verify.js +56 -0
- package/dist/write/approval.d.ts +5 -0
- package/dist/write/approval.js +95 -0
- package/dist/write/attest.d.ts +14 -0
- package/dist/write/attest.js +140 -0
- package/dist/write/config.d.ts +11 -0
- package/dist/write/config.js +12 -0
- package/dist/write/contracts.d.ts +229 -0
- package/dist/write/contracts.js +61 -0
- package/dist/write/post.d.ts +11 -0
- package/dist/write/post.js +105 -0
- package/dist/write/profile.d.ts +19 -0
- package/dist/write/profile.js +114 -0
- package/dist/write/seal.d.ts +3 -0
- package/dist/write/seal.js +49 -0
- package/dist/write-tools.d.ts +4 -0
- package/dist/write-tools.js +36 -0
- package/docs/age-version-compatibility.md +46 -0
- package/docs/architecture.md +72 -0
- package/docs/compatibility.md +163 -0
- package/docs/contracts.md +127 -0
- package/docs/examples/customer-claude-desktop.json +14 -0
- package/docs/examples/customer-consent.json +15 -0
- package/docs/examples/customer-custody.json +8 -0
- package/docs/examples/customer-policy.json +43 -0
- package/docs/licensing-review.md +109 -0
- package/docs/milestone-1-validation.md +110 -0
- package/docs/milestone-2.md +291 -0
- package/docs/milestone-3.2.md +291 -0
- package/docs/milestone-3.md +274 -0
- package/docs/milestone-4a.md +221 -0
- package/docs/milestone-4b1.md +220 -0
- package/docs/milestone-4b2.md +260 -0
- package/docs/public-default.md +263 -0
- package/docs/recording-schema-compatibility.md +46 -0
- package/docs/release.md +311 -0
- package/docs/security-fixes.md +47 -0
- package/docs/security.md +195 -0
- package/docs/standalone-acceptance.md +81 -0
- package/docs/validation.md +85 -0
- package/package.json +51 -4
- package/server.json +20 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import * as z from 'zod/v4';
|
|
2
|
+
import { createHash } from 'node:crypto';
|
|
3
|
+
import { NODE_ORIGIN } from '../network/client.js';
|
|
4
|
+
import { disclosureEligible, LEGACY_DISCLOSURE, OPENAI_DISCLOSURE, validV2 } from '../write/profile.js';
|
|
5
|
+
const label = z.string().regex(/^[A-Za-z0-9._:-]{1,128}$/);
|
|
6
|
+
const date = z.iso.datetime();
|
|
7
|
+
export const ownerPolicy = z.strictObject({
|
|
8
|
+
version: z.literal(1), id: label, revision: z.number().int().positive(),
|
|
9
|
+
accountContext: label, credentialContext: label,
|
|
10
|
+
credentialFingerprint: z.string().regex(/^[0-9a-f]{64}$/),
|
|
11
|
+
destination: z.literal(`${NODE_ORIGIN}/api/attest`),
|
|
12
|
+
evidenceTypes: z.array(z.literal('cer.ai.execution.v2')).min(1).max(1),
|
|
13
|
+
captureSources: z.array(z.enum(['producer_supplied', 'instrumented_provider_call'])).min(1).max(2),
|
|
14
|
+
visibilities: z.array(z.enum(['public', 'private'])).min(1).max(2),
|
|
15
|
+
requiredConfidentialFields: z.array(z.enum(['input', 'output', 'instruction', 'decisionRefs'])).min(2).max(4),
|
|
16
|
+
// Exact JSON-pointer leaf paths, including array indices. No wildcards.
|
|
17
|
+
readableFields: z.array(z.string().regex(/^\/[A-Za-z0-9_/-]+$/)).min(1).max(256),
|
|
18
|
+
identityDisclosure: z.enum(['forbid', 'declared_allowlisted']).default('forbid'),
|
|
19
|
+
nodeDisclosureProfile: z.enum([LEGACY_DISCLOSURE, OPENAI_DISCLOSURE]),
|
|
20
|
+
maximumCertifications: z.number().int().min(1).max(1_000_000),
|
|
21
|
+
periodStartsAt: date, periodEndsAt: date, expiresAt: date, revoked: z.boolean(),
|
|
22
|
+
}).superRefine((p, ctx) => {
|
|
23
|
+
if (!p.requiredConfidentialFields.includes('input') || !p.requiredConfidentialFields.includes('output') ||
|
|
24
|
+
Date.parse(p.periodStartsAt) >= Date.parse(p.periodEndsAt) ||
|
|
25
|
+
Date.parse(p.expiresAt) > Date.parse(p.periodEndsAt))
|
|
26
|
+
ctx.addIssue({ code: 'custom', message: 'Invalid required protections or approved period' });
|
|
27
|
+
});
|
|
28
|
+
// Local control-plane digests only. CER hashes/commitments always come from SDK.
|
|
29
|
+
export const controlDigest = (text) => createHash('sha256').update(text).digest('hex');
|
|
30
|
+
export function readableLeafPaths(value, path = '') {
|
|
31
|
+
if (value === null || typeof value !== 'object')
|
|
32
|
+
return [path];
|
|
33
|
+
return Object.entries(value).flatMap(([key, child]) => readableLeafPaths(child, `${path}/${key}`));
|
|
34
|
+
}
|
|
35
|
+
/** A field allowlist is not a semantic PII detector. Approving readable paths
|
|
36
|
+
* authorizes their values; public metadata remains subject to the existing profile. */
|
|
37
|
+
export function evaluatePolicy(raw, record, account, credentialContext, key, now = Date.now()) {
|
|
38
|
+
const p = ownerPolicy.parse(raw);
|
|
39
|
+
if (p.revoked || now < Date.parse(p.periodStartsAt) || now >= Date.parse(p.periodEndsAt) ||
|
|
40
|
+
now >= Date.parse(p.expiresAt) || p.accountContext !== account ||
|
|
41
|
+
p.credentialContext !== credentialContext || p.credentialFingerprint !== controlDigest(key) ||
|
|
42
|
+
!key || /[\r\n]/.test(key))
|
|
43
|
+
throw Error('POLICY_AUTHORIZATION_DENIED');
|
|
44
|
+
const bundle = JSON.parse(record.body);
|
|
45
|
+
if (!validV2(bundle) || bundle.certificateHash !== record.certificateHash ||
|
|
46
|
+
!disclosureEligible(bundle, record.visibility, p.nodeDisclosureProfile) || !p.evidenceTypes.includes(bundle.bundleType) ||
|
|
47
|
+
!p.captureSources.includes(record.captureSource) || !p.visibilities.includes(record.visibility))
|
|
48
|
+
throw Error('POLICY_PROFILE_DENIED');
|
|
49
|
+
const s = bundle.snapshot;
|
|
50
|
+
if (s.identity !== undefined && p.identityDisclosure === 'forbid')
|
|
51
|
+
throw Error('POLICY_IDENTITY_DENIED');
|
|
52
|
+
for (const field of p.requiredConfidentialFields) {
|
|
53
|
+
if (field === 'decisionRefs') {
|
|
54
|
+
if (!Array.isArray(s.decisionRefs) || !s.decisionRefs.length)
|
|
55
|
+
throw Error('POLICY_PROTECTION_REQUIRED');
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
const v = s[field];
|
|
59
|
+
if (!v || v._redacted !== true || v.mode !== 'confidential')
|
|
60
|
+
throw Error('POLICY_PROTECTION_REQUIRED');
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (readableLeafPaths(bundle).some(path => !p.readableFields.includes(path)))
|
|
64
|
+
throw Error('POLICY_DISCLOSURE_DENIED');
|
|
65
|
+
return p;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=policy.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type AttestDependencies } from '../write/attest.js';
|
|
2
|
+
import type { PreparedRecord, PublicationResult } from './contracts.js';
|
|
3
|
+
/** Trusted application configuration, never MCP arguments. Isolated owner and
|
|
4
|
+
* explicitly consented customer delegation use the same exact-body pipeline. */
|
|
5
|
+
export interface OwnerPublicationOptions {
|
|
6
|
+
policyFile: string;
|
|
7
|
+
stateDirectory: string;
|
|
8
|
+
approvalDirectory: string;
|
|
9
|
+
accountContext: string;
|
|
10
|
+
credentialContext: string;
|
|
11
|
+
credential: () => string | undefined;
|
|
12
|
+
}
|
|
13
|
+
export declare function publishForTrustedApplication(record: PreparedRecord, options: OwnerPublicationOptions, dependencies?: AttestDependencies): Promise<PublicationResult>;
|
|
14
|
+
/** Only these constant control diagnostics may cross the publisher boundary. */
|
|
15
|
+
export declare class PublicationControlError extends Error {
|
|
16
|
+
readonly reasonCode: 'CUSTOMER_CONSENT_REQUIRED' | 'CUSTOMER_CONSENT_EXPIRED_OR_REVOKED' | 'CUSTOMER_CONSENT_CHANGED' | 'CUSTOMER_CERTIFICATION_CONFIG_INVALID';
|
|
17
|
+
constructor(reasonCode: 'CUSTOMER_CONSENT_REQUIRED' | 'CUSTOMER_CONSENT_EXPIRED_OR_REVOKED' | 'CUSTOMER_CONSENT_CHANGED' | 'CUSTOMER_CERTIFICATION_CONFIG_INVALID');
|
|
18
|
+
}
|
|
19
|
+
/** Shared transport, policy, approval and attempt core. No mode bypass flag.
|
|
20
|
+
* Customer entry validates consent; isolated entry retains requireIsolatedMac. */
|
|
21
|
+
export declare function publishWithPolicy(record: PreparedRecord, options: OwnerPublicationOptions, dependencies?: AttestDependencies, controls?: {
|
|
22
|
+
recheck: () => void;
|
|
23
|
+
}): Promise<PublicationResult>;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { dirname, join } from 'node:path';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import { readOwnerInput, ownerDirectory } from '../owner/create.js';
|
|
4
|
+
import { issueApproval, consumeApproval } from '../write/approval.js';
|
|
5
|
+
import { attest } from '../write/attest.js';
|
|
6
|
+
import { writeConfig } from '../write/config.js';
|
|
7
|
+
import { AttestPoster } from '../write/post.js';
|
|
8
|
+
import { evaluatePolicy, controlDigest } from './policy.js';
|
|
9
|
+
import { reserveAttempt, retainOutcome, attemptName } from './state.js';
|
|
10
|
+
function denied(reasonCode) {
|
|
11
|
+
return { authorization: 'authorization_denied', submission: 'not_sent',
|
|
12
|
+
nodeConfirmedVisibility: null, reasonCode, receiptSignature: 'not_performed',
|
|
13
|
+
hashBinding: 'not_performed', signerTrust: 'not_established', reservedAttempts: null };
|
|
14
|
+
}
|
|
15
|
+
function readPolicy(path) {
|
|
16
|
+
ownerDirectory(dirname(path));
|
|
17
|
+
return readOwnerInput(path);
|
|
18
|
+
}
|
|
19
|
+
class PolicyBoundPoster extends AttestPoster {
|
|
20
|
+
delegate;
|
|
21
|
+
check;
|
|
22
|
+
constructor(delegate, check) {
|
|
23
|
+
super();
|
|
24
|
+
this.delegate = delegate;
|
|
25
|
+
this.check = check;
|
|
26
|
+
}
|
|
27
|
+
async submit(body, visibility, key, signal) {
|
|
28
|
+
this.check(body, visibility, key);
|
|
29
|
+
return this.delegate.submit(body, visibility, key, signal);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export async function publishForTrustedApplication(record, options, dependencies = {}) {
|
|
33
|
+
return publishWithPolicy(record, options, dependencies);
|
|
34
|
+
}
|
|
35
|
+
/** Only these constant control diagnostics may cross the publisher boundary. */
|
|
36
|
+
export class PublicationControlError extends Error {
|
|
37
|
+
reasonCode;
|
|
38
|
+
constructor(reasonCode) {
|
|
39
|
+
super(reasonCode);
|
|
40
|
+
this.reasonCode = reasonCode;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/** Shared transport, policy, approval and attempt core. No mode bypass flag.
|
|
44
|
+
* Customer entry validates consent; isolated entry retains requireIsolatedMac. */
|
|
45
|
+
export async function publishWithPolicy(record, options, dependencies = {}, controls) {
|
|
46
|
+
// Library-only dependency injection is identical to the existing attest API;
|
|
47
|
+
// neither dependencies nor owner configuration are accepted over MCP.
|
|
48
|
+
record = Object.freeze({ ...record });
|
|
49
|
+
let key = '', reservation;
|
|
50
|
+
let config;
|
|
51
|
+
let grantCreated = false;
|
|
52
|
+
let policyAuthorized = false;
|
|
53
|
+
let controlFailure;
|
|
54
|
+
const recheck = () => {
|
|
55
|
+
try {
|
|
56
|
+
controls?.recheck();
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
if (error instanceof PublicationControlError)
|
|
60
|
+
controlFailure = error;
|
|
61
|
+
throw error;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
try {
|
|
65
|
+
recheck();
|
|
66
|
+
const raw = readPolicy(options.policyFile);
|
|
67
|
+
key = options.credential() ?? '';
|
|
68
|
+
if (!key)
|
|
69
|
+
return { ...denied('NODE_CREDENTIAL_UNAVAILABLE'), authorization: 'setup_required' };
|
|
70
|
+
const policy = evaluatePolicy(raw, record, options.accountContext, options.credentialContext, key);
|
|
71
|
+
policyAuthorized = true;
|
|
72
|
+
ownerDirectory(options.approvalDirectory);
|
|
73
|
+
// Bind an immutable internal snapshot, not mutable caller objects.
|
|
74
|
+
const policyBytes = JSON.stringify(raw);
|
|
75
|
+
const bundle = JSON.parse(record.body);
|
|
76
|
+
if (JSON.stringify(bundle) !== record.body)
|
|
77
|
+
return denied('NONEXACT_BODY_REJECTED');
|
|
78
|
+
reservation = reserveAttempt(options.stateDirectory, policy, record, policyBytes);
|
|
79
|
+
// Recheck revocation/expiry/change after durable reservation and immediately
|
|
80
|
+
// before exact-body authorization. Changes burn this reservation, not retry.
|
|
81
|
+
const current = readPolicy(options.policyFile);
|
|
82
|
+
policyAuthorized = false;
|
|
83
|
+
recheck();
|
|
84
|
+
if (controlDigest(JSON.stringify(current)) !== controlDigest(policyBytes))
|
|
85
|
+
throw Error('POLICY_CHANGED');
|
|
86
|
+
evaluatePolicy(current, record, options.accountContext, options.credentialContext, key);
|
|
87
|
+
policyAuthorized = true;
|
|
88
|
+
config = writeConfig({
|
|
89
|
+
NEXART_ENABLE_ATTEST: 'true', NEXART_ENABLE_PUBLIC_ATTEST: 'true',
|
|
90
|
+
NEXART_PUBLIC_APPROVAL_DIRECTORY: options.approvalDirectory,
|
|
91
|
+
NEXART_NODE_ACCOUNT_CONTEXT: options.accountContext, NEXART_NODE_API_KEY: key,
|
|
92
|
+
});
|
|
93
|
+
if (record.visibility === 'public') {
|
|
94
|
+
issueApproval(config, record.body, key);
|
|
95
|
+
grantCreated = true;
|
|
96
|
+
}
|
|
97
|
+
const poster = new PolicyBoundPoster(dependencies.poster ?? new AttestPoster(), (body, visibility, credential) => {
|
|
98
|
+
policyAuthorized = false;
|
|
99
|
+
recheck();
|
|
100
|
+
if (body !== record.body || visibility !== record.visibility || credential !== key)
|
|
101
|
+
throw Error('EXACT_TRANSACTION_REQUIRED');
|
|
102
|
+
const latest = readPolicy(options.policyFile);
|
|
103
|
+
if (controlDigest(JSON.stringify(latest)) !== controlDigest(policyBytes))
|
|
104
|
+
throw Error('POLICY_CHANGED_BEFORE_POST');
|
|
105
|
+
evaluatePolicy(latest, record, options.accountContext, options.credentialContext, credential);
|
|
106
|
+
policyAuthorized = true;
|
|
107
|
+
});
|
|
108
|
+
const response = await attest({
|
|
109
|
+
certificateHash: record.certificateHash, bundle, visibility: record.visibility,
|
|
110
|
+
}, config, { ...dependencies, poster, disclosureProfile: policy.nodeDisclosureProfile });
|
|
111
|
+
const outcome = {
|
|
112
|
+
authorization: policyAuthorized ? 'policy_authorized' : 'authorization_denied',
|
|
113
|
+
// A consent callback failed before the delegate transport was invoked.
|
|
114
|
+
// Keep the burned reservation, but do not misreport an actual POST.
|
|
115
|
+
submission: controlFailure ? 'not_sent' : response.submission,
|
|
116
|
+
nodeConfirmedVisibility: response.nodeConfirmedVisibility, reasonCode: controlFailure?.reasonCode ?? response.reasonCode,
|
|
117
|
+
receiptSignature: response.receipt?.signature ?? 'not_performed',
|
|
118
|
+
hashBinding: response.receipt?.hashBinding ?? 'not_performed',
|
|
119
|
+
signerTrust: response.receipt?.signerTrust ?? 'not_established',
|
|
120
|
+
reservedAttempts: reservation.count,
|
|
121
|
+
};
|
|
122
|
+
// Exclusive outcome record; original marker is NEVER rewritten or removed.
|
|
123
|
+
retainOutcome(options.stateDirectory, reservation.file, outcome);
|
|
124
|
+
return outcome;
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
// Reservation may have persisted even if fsync failed. Never clear state.
|
|
128
|
+
const persisted = existsSync(join(options.stateDirectory, `${attemptName(options.accountContext, record.certificateHash)}.attempt.json`));
|
|
129
|
+
return reservation || persisted
|
|
130
|
+
? { ...denied('ATTEMPT_REQUIRES_OWNER_RECONCILIATION'), authorization: policyAuthorized ? 'policy_authorized' : 'authorization_denied',
|
|
131
|
+
submission: 'outcome_unknown', reservedAttempts: reservation?.count ?? null }
|
|
132
|
+
: controlFailure
|
|
133
|
+
? { ...denied(controlFailure.reasonCode), authorization: 'setup_required' }
|
|
134
|
+
: denied(controls && error instanceof Error && [
|
|
135
|
+
'PUBLISHER_LOCAL_BUDGET_EXHAUSTED', 'ATTEMPT_RESERVATION_BUSY',
|
|
136
|
+
'POLICY_AUTHORIZATION_DENIED', 'POLICY_PROFILE_DENIED', 'POLICY_IDENTITY_DENIED',
|
|
137
|
+
'POLICY_PROTECTION_REQUIRED', 'POLICY_DISCLOSURE_DENIED',
|
|
138
|
+
].includes(error.message) ? error.message : 'OWNER_POLICY_OR_ATTEMPT_DENIED');
|
|
139
|
+
}
|
|
140
|
+
finally {
|
|
141
|
+
// Revoke a leftover public grant when validation/cancellation failed before
|
|
142
|
+
// consumption. The durable attempt still burns its local allowance.
|
|
143
|
+
if (grantCreated && config)
|
|
144
|
+
consumeApproval(config, record.body, key);
|
|
145
|
+
key = '';
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=publication.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type EncryptedCustody } from '../owner/custody.js';
|
|
2
|
+
import { type CaptureSource, type RecordResult, type PreparedRecord, type PublicationResult } from './contracts.js';
|
|
3
|
+
/** Trusted application configuration, never MCP arguments. Credential discovery
|
|
4
|
+
* belongs to the explicitly configured publisher, not this recording library. */
|
|
5
|
+
export interface RecordRuntime {
|
|
6
|
+
custodyDirectory?: string;
|
|
7
|
+
recoveryStorage?: 'unencrypted_owner_approved';
|
|
8
|
+
encryptedCustody?: EncryptedCustody;
|
|
9
|
+
captureSource?: CaptureSource;
|
|
10
|
+
publish?: (record: PreparedRecord) => Promise<PublicationResult>;
|
|
11
|
+
}
|
|
12
|
+
export declare function recordExecution(raw: unknown, runtime?: RecordRuntime): Promise<RecordResult>;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
import { verifyConfidentialV2 } from '@nexart/ai-execution';
|
|
3
|
+
import { createOwnerConfidential, readOwnerInput } from '../owner/create.js';
|
|
4
|
+
import { createEncryptedConfidential, EncryptedCustodyError } from '../owner/custody.js';
|
|
5
|
+
import { boundedInput, validV2 } from '../write/profile.js';
|
|
6
|
+
import { recordInput } from './contracts.js';
|
|
7
|
+
export async function recordExecution(raw, runtime = {}) {
|
|
8
|
+
const result = {
|
|
9
|
+
contractVersion: '1', captureProvenance: runtime.captureSource ?? 'producer_supplied',
|
|
10
|
+
evidence: 'not_created', custody: 'not_performed', localIntegrity: 'not_performed',
|
|
11
|
+
certificationIntent: 'node', policyAuthorization: 'setup_required', submission: 'not_sent',
|
|
12
|
+
requestedVisibility: 'public', nodeConfirmedVisibility: null, certificateHash: null,
|
|
13
|
+
receiptSignature: 'not_performed', hashBinding: 'not_performed', signerTrust: 'not_established',
|
|
14
|
+
reasonCode: 'INVALID_ARGUMENTS',
|
|
15
|
+
usage: { authoritative: false, accountRemaining: null, scope: 'publisher_local', reservedAttempts: null },
|
|
16
|
+
};
|
|
17
|
+
try {
|
|
18
|
+
if (boundedInput(raw))
|
|
19
|
+
return result;
|
|
20
|
+
const parsed = recordInput.safeParse(raw);
|
|
21
|
+
if (!parsed.success)
|
|
22
|
+
return result;
|
|
23
|
+
const input = parsed.data, mode = input.certification?.mode ?? 'node';
|
|
24
|
+
const visibility = input.certification?.visibility ?? 'public';
|
|
25
|
+
result.certificationIntent = mode;
|
|
26
|
+
result.requestedVisibility = mode === 'node' ? visibility : null;
|
|
27
|
+
result.policyAuthorization = mode === 'local' ? 'not_required' : 'setup_required';
|
|
28
|
+
let bundle;
|
|
29
|
+
if (input.kind === 'execution') {
|
|
30
|
+
if (!runtime.encryptedCustody && (!runtime.custodyDirectory || runtime.recoveryStorage !== 'unencrypted_owner_approved')) {
|
|
31
|
+
return { ...result, evidence: 'custody_failed', reasonCode: 'APPROVED_CUSTODY_REQUIRED' };
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
// Protect instruction/decision references when present, as well as IO.
|
|
35
|
+
// No salt input and no opening output. Reuse the durable owner workflow.
|
|
36
|
+
const creation = {
|
|
37
|
+
execution: input.execution, createdAt: input.createdAt,
|
|
38
|
+
protectInstruction: input.execution.instruction !== undefined,
|
|
39
|
+
decisionRefIndexes: Array.isArray(input.execution.decisionRefs)
|
|
40
|
+
? input.execution.decisionRefs.map((_, i) => i) : [],
|
|
41
|
+
};
|
|
42
|
+
if (runtime.encryptedCustody) {
|
|
43
|
+
bundle = createEncryptedConfidential(creation, runtime.encryptedCustody);
|
|
44
|
+
result.custody = 'encrypted_owner_recipient';
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
const created = createOwnerConfidential(creation, runtime.custodyDirectory);
|
|
48
|
+
bundle = readOwnerInput(join(runtime.custodyDirectory, created.certificateHash.replace(':', '-'), 'cer.json'));
|
|
49
|
+
result.custody = 'unencrypted_owner_approved';
|
|
50
|
+
}
|
|
51
|
+
result.evidence = 'created_confidential';
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
return { ...result, evidence: 'custody_failed', reasonCode: error instanceof EncryptedCustodyError
|
|
55
|
+
? error.reasonCode : runtime.encryptedCustody
|
|
56
|
+
? 'ENCRYPTED_CREATION_OR_CUSTODY_FAILED' : 'CONFIDENTIAL_CREATION_OR_CUSTODY_FAILED' };
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
bundle = input.bundle;
|
|
61
|
+
result.evidence = 'existing_unchanged';
|
|
62
|
+
result.custody = 'external_existing_cer';
|
|
63
|
+
}
|
|
64
|
+
if (!validV2(bundle) || verifyConfidentialV2(bundle).state !== 'AUTHENTIC') {
|
|
65
|
+
return { ...result, evidence: 'invalid', localIntegrity: 'invalid', reasonCode: 'INVALID_CONFIDENTIAL_AI_V2' };
|
|
66
|
+
}
|
|
67
|
+
result.localIntegrity = 'valid';
|
|
68
|
+
result.certificateHash = bundle.certificateHash;
|
|
69
|
+
if (mode === 'local')
|
|
70
|
+
return { ...result, reasonCode: 'LOCAL_ONLY_EVIDENCE_SEALED' };
|
|
71
|
+
if (!runtime.publish)
|
|
72
|
+
return { ...result, reasonCode: 'OWNER_PUBLISHER_SETUP_REQUIRED' };
|
|
73
|
+
// Snapshot once; mutation of the caller object cannot change approved bytes.
|
|
74
|
+
const prepared = Object.freeze({
|
|
75
|
+
body: JSON.stringify(bundle), certificateHash: bundle.certificateHash,
|
|
76
|
+
visibility, captureSource: result.captureProvenance,
|
|
77
|
+
});
|
|
78
|
+
const published = await runtime.publish(prepared);
|
|
79
|
+
return {
|
|
80
|
+
...result, policyAuthorization: published.authorization, submission: published.submission,
|
|
81
|
+
nodeConfirmedVisibility: published.nodeConfirmedVisibility, reasonCode: published.reasonCode,
|
|
82
|
+
receiptSignature: published.receiptSignature, hashBinding: published.hashBinding,
|
|
83
|
+
signerTrust: published.signerTrust,
|
|
84
|
+
usage: { ...result.usage, reservedAttempts: published.reservedAttempts },
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
// A custom trusted port may have sent before throwing; never imply safe retry.
|
|
89
|
+
return { ...result, reasonCode: 'OWNER_PUBLISHER_OUTCOME_UNKNOWN',
|
|
90
|
+
submission: runtime.publish && result.localIntegrity === 'valid' ? 'outcome_unknown' : 'not_sent' };
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=record.js.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import * as z from 'zod/v4';
|
|
2
|
+
import { type OwnerPolicy } from './policy.js';
|
|
3
|
+
import type { PreparedRecord } from './contracts.js';
|
|
4
|
+
export declare function durableExclusive(path: string, value: unknown): void;
|
|
5
|
+
export declare function attemptName(account: string, hash: string): string;
|
|
6
|
+
export interface Attempt {
|
|
7
|
+
version: 1;
|
|
8
|
+
accountContext: string;
|
|
9
|
+
policyId: string;
|
|
10
|
+
policyRevision: number;
|
|
11
|
+
policyDigest: string;
|
|
12
|
+
certificateHash: string;
|
|
13
|
+
body: string;
|
|
14
|
+
visibility: 'public' | 'private';
|
|
15
|
+
captureSource: string;
|
|
16
|
+
reservedAt: string;
|
|
17
|
+
state: 'potentially_sent_do_not_repeat';
|
|
18
|
+
}
|
|
19
|
+
export declare const attemptSchema: z.ZodObject<{
|
|
20
|
+
version: z.ZodLiteral<1>;
|
|
21
|
+
accountContext: z.ZodString;
|
|
22
|
+
policyId: z.ZodString;
|
|
23
|
+
policyRevision: z.ZodNumber;
|
|
24
|
+
policyDigest: z.ZodString;
|
|
25
|
+
certificateHash: z.ZodString;
|
|
26
|
+
body: z.ZodString;
|
|
27
|
+
visibility: z.ZodEnum<{
|
|
28
|
+
private: "private";
|
|
29
|
+
public: "public";
|
|
30
|
+
}>;
|
|
31
|
+
captureSource: z.ZodEnum<{
|
|
32
|
+
producer_supplied: "producer_supplied";
|
|
33
|
+
instrumented_provider_call: "instrumented_provider_call";
|
|
34
|
+
}>;
|
|
35
|
+
reservedAt: z.ZodISODateTime;
|
|
36
|
+
state: z.ZodLiteral<"potentially_sent_do_not_repeat">;
|
|
37
|
+
}, z.core.$strict>;
|
|
38
|
+
/** Synchronous lock/reserve spans processes. A stale lock is a fail-closed
|
|
39
|
+
* administrative reconciliation event, never an automatically cleared lock. */
|
|
40
|
+
export declare function reserveAttempt(stateDirectory: string, policy: OwnerPolicy, record: PreparedRecord, policyBytes: string, now?: number): {
|
|
41
|
+
file: string;
|
|
42
|
+
count: number;
|
|
43
|
+
};
|
|
44
|
+
export declare function retainOutcome(stateDirectory: string, file: string, outcome: unknown): void;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { constants, openSync, writeFileSync, fsyncSync, closeSync, mkdirSync, rmdirSync, readdirSync, } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import * as z from 'zod/v4';
|
|
4
|
+
import { ownerDirectory, readOwnerInput } from '../owner/create.js';
|
|
5
|
+
import { controlDigest } from './policy.js';
|
|
6
|
+
import { boundedInput } from '../write/profile.js';
|
|
7
|
+
import { hashSchema } from '../network/contracts.js';
|
|
8
|
+
export function durableExclusive(path, value) {
|
|
9
|
+
const fd = openSync(path, constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW, 0o600);
|
|
10
|
+
try {
|
|
11
|
+
writeFileSync(fd, JSON.stringify(value));
|
|
12
|
+
fsyncSync(fd);
|
|
13
|
+
}
|
|
14
|
+
finally {
|
|
15
|
+
closeSync(fd);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function syncDirectory(path) {
|
|
19
|
+
const fd = openSync(path, constants.O_RDONLY);
|
|
20
|
+
try {
|
|
21
|
+
fsyncSync(fd);
|
|
22
|
+
}
|
|
23
|
+
finally {
|
|
24
|
+
closeSync(fd);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export function attemptName(account, hash) {
|
|
28
|
+
return controlDigest(JSON.stringify({ account, hash }));
|
|
29
|
+
}
|
|
30
|
+
export const attemptSchema = z.strictObject({
|
|
31
|
+
version: z.literal(1), accountContext: z.string().min(1), policyId: z.string().min(1),
|
|
32
|
+
policyRevision: z.number().int().positive(), policyDigest: z.string().regex(/^[0-9a-f]{64}$/),
|
|
33
|
+
certificateHash: hashSchema, body: z.string().min(1), visibility: z.enum(['public', 'private']),
|
|
34
|
+
captureSource: z.enum(['producer_supplied', 'instrumented_provider_call']),
|
|
35
|
+
reservedAt: z.iso.datetime(), state: z.literal('potentially_sent_do_not_repeat'),
|
|
36
|
+
});
|
|
37
|
+
/** Synchronous lock/reserve spans processes. A stale lock is a fail-closed
|
|
38
|
+
* administrative reconciliation event, never an automatically cleared lock. */
|
|
39
|
+
export function reserveAttempt(stateDirectory, policy, record, policyBytes, now = Date.now()) {
|
|
40
|
+
ownerDirectory(stateDirectory);
|
|
41
|
+
const lock = join(stateDirectory, 'reservation.lock');
|
|
42
|
+
try {
|
|
43
|
+
mkdirSync(lock, { mode: 0o700 });
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
throw Error('ATTEMPT_RESERVATION_BUSY');
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
let count = 0;
|
|
50
|
+
for (const name of readdirSync(stateDirectory)) {
|
|
51
|
+
if (!/^[0-9a-f]{64}\.attempt\.json$/.test(name))
|
|
52
|
+
continue;
|
|
53
|
+
const a = attemptSchema.parse(readOwnerInput(join(stateDirectory, name)));
|
|
54
|
+
if (name !== `${attemptName(a.accountContext, a.certificateHash)}.attempt.json`)
|
|
55
|
+
throw Error('ATTEMPT_STATE_REJECTED');
|
|
56
|
+
if (a.accountContext === policy.accountContext && a.policyId === policy.id &&
|
|
57
|
+
Date.parse(a.reservedAt) >= Date.parse(policy.periodStartsAt) &&
|
|
58
|
+
Date.parse(a.reservedAt) < Date.parse(policy.periodEndsAt))
|
|
59
|
+
count++;
|
|
60
|
+
}
|
|
61
|
+
if (count >= policy.maximumCertifications)
|
|
62
|
+
throw Error('PUBLISHER_LOCAL_BUDGET_EXHAUSTED');
|
|
63
|
+
const file = join(stateDirectory, `${attemptName(policy.accountContext, record.certificateHash)}.attempt.json`);
|
|
64
|
+
const attempt = {
|
|
65
|
+
version: 1, accountContext: policy.accountContext, policyId: policy.id, policyRevision: policy.revision,
|
|
66
|
+
policyDigest: controlDigest(policyBytes), certificateHash: record.certificateHash, body: record.body,
|
|
67
|
+
visibility: record.visibility, captureSource: record.captureSource,
|
|
68
|
+
reservedAt: new Date(now).toISOString(), state: 'potentially_sent_do_not_repeat',
|
|
69
|
+
};
|
|
70
|
+
if (boundedInput(attempt))
|
|
71
|
+
throw Error('ATTEMPT_STATE_TOO_LARGE');
|
|
72
|
+
durableExclusive(file, attempt);
|
|
73
|
+
syncDirectory(stateDirectory); // Must complete before any grant or POST.
|
|
74
|
+
return { file, count: count + 1 };
|
|
75
|
+
}
|
|
76
|
+
finally {
|
|
77
|
+
rmdirSync(lock);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
export function retainOutcome(stateDirectory, file, outcome) {
|
|
81
|
+
durableExclusive(`${file}.outcome.json`, outcome);
|
|
82
|
+
syncDirectory(stateDirectory);
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=state.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { McpServer } from '@modelcontextprotocol/server';
|
|
2
|
+
import { type EncryptedCustody } from './owner/custody.js';
|
|
3
|
+
import type { RecordRuntime } from './record/record.js';
|
|
4
|
+
export interface RecordingConfig {
|
|
5
|
+
enabled: boolean;
|
|
6
|
+
custody?: EncryptedCustody;
|
|
7
|
+
publish?: RecordRuntime['publish'];
|
|
8
|
+
}
|
|
9
|
+
export declare function recordingConfig(env?: NodeJS.ProcessEnv): RecordingConfig;
|
|
10
|
+
export declare function registerRecordingTool(server: McpServer, config?: RecordingConfig): void;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import * as z from 'zod/v4';
|
|
2
|
+
import { dirname } from 'node:path';
|
|
3
|
+
import { ownerDirectory, readOwnerInput } from './owner/create.js';
|
|
4
|
+
import {} from './owner/custody.js';
|
|
5
|
+
import { mcpRecordInput, recordDiscoveryInput, recordOutput } from './record/contracts.js';
|
|
6
|
+
import { recordExecution } from './record/record.js';
|
|
7
|
+
import { createCustomerPublisher } from './record/customer.js';
|
|
8
|
+
import { writeConfig } from './write/config.js';
|
|
9
|
+
const custodyConfig = z.strictObject({
|
|
10
|
+
version: z.literal(1), directory: z.string().min(1), ageExecutable: z.string().min(1),
|
|
11
|
+
recipient: z.string().min(1), ownerApproved: z.literal(true), decryptionIdentityExcluded: z.literal(true),
|
|
12
|
+
});
|
|
13
|
+
// Constant guidance only: never interpolate credentials, arguments or paths.
|
|
14
|
+
const SETUP_MESSAGES = Object.freeze({
|
|
15
|
+
CUSTODY_CONFIG_MISSING: 'Configure the owner-only NEXART_RECORD_CUSTODY_CONFIG JSON before execution recording.',
|
|
16
|
+
CUSTODY_CONFIG_INVALID: 'Check custody JSON, recipient, executable real path and owner-only file/directory permissions.',
|
|
17
|
+
ENCRYPTED_CUSTODY_CONFIGURATION_REQUIRED: 'Check the custody recipient, executable real path and owner-only directory permissions.',
|
|
18
|
+
AGE_VERSION_UNSUPPORTED: 'Use a stable age release at least 1.2.1 and below 2.0.0, with an optional leading v in version output.',
|
|
19
|
+
AGE_VERSION_CHECK_FAILED: 'The age version command failed or timed out. Check the locally configured executable.',
|
|
20
|
+
OWNER_PUBLISHER_SETUP_REQUIRED: 'Configure NEXART_RECORD_CERTIFICATION_CONFIG and explicitly approve customer delegation. A key alone does not enable certification.',
|
|
21
|
+
CUSTOMER_CERTIFICATION_CONFIG_INVALID: 'Check the versioned customer consent JSON, absolute paths and owner-only file/directory permissions.',
|
|
22
|
+
CUSTOMER_CONSENT_REQUIRED: 'The owner must review and enable automatic submissions, public disclosure and quota acknowledgements in local configuration.',
|
|
23
|
+
CUSTOMER_CONSENT_EXPIRED_OR_REVOKED: 'Customer consent is expired or revoked. Only the owner should decide whether to renew it.',
|
|
24
|
+
CUSTOMER_CONSENT_CHANGED: 'Consent changed during this transaction. Inspect the retained attempt before taking further action; do not retry automatically.',
|
|
25
|
+
NODE_CREDENTIAL_UNAVAILABLE: 'Configure the customer-owned NEXART_NODE_API_KEY locally. Never paste a key into chat or tool arguments.',
|
|
26
|
+
NODE_AUTH_REJECTED: 'The Node rejected authentication. Check or rotate the customer key locally and update the policy fingerprint. Do not repeat this attempted CER.',
|
|
27
|
+
POLICY_AUTHORIZATION_DENIED: 'Check owner policy expiry, revocation, context and credential fingerprint. Do not broaden policy automatically.',
|
|
28
|
+
POLICY_PROFILE_DENIED: 'Evidence is not eligible under the approved disclosure profile. Do not strip or reseal fields to force submission.',
|
|
29
|
+
POLICY_DISCLOSURE_DENIED: 'Readable fields exceed the owner-approved disclosure allowlist. The owner must review the disclosure.',
|
|
30
|
+
POLICY_IDENTITY_DENIED: 'Producer identity disclosure has not been approved by the owner.',
|
|
31
|
+
POLICY_PROTECTION_REQUIRED: 'Required confidential content protection is missing. No submission was authorized.',
|
|
32
|
+
PUBLISHER_LOCAL_BUDGET_EXHAUSTED: 'The local attempt allowance is exhausted. Stop for owner review; this is not a Node account-wide quota measurement.',
|
|
33
|
+
ATTEMPT_RESERVATION_BUSY: 'A concurrent or stale attempt lock blocks submission. Owner inspection is required; do not clear it automatically.',
|
|
34
|
+
ATTEMPT_REQUIRES_OWNER_RECONCILIATION: 'An attempt already exists or its outcome is uncertain. Use owner-authorized GET reconciliation; do not repeat POST.',
|
|
35
|
+
NODE_QUOTA_OR_RATE_LIMITED: 'The Node returned a quota or rate-limit response. No remaining balance is known and no automatic retry will occur.',
|
|
36
|
+
});
|
|
37
|
+
// Keep only constant classifications, never the underlying filesystem error.
|
|
38
|
+
const custodySetupDiagnostics = new WeakMap();
|
|
39
|
+
export function recordingConfig(env = process.env) {
|
|
40
|
+
const result = { enabled: env.NEXART_ENABLE_RECORD === 'true' };
|
|
41
|
+
if (result.enabled && env.NEXART_RECORD_CERTIFICATION_CONFIG) {
|
|
42
|
+
result.publish = createCustomerPublisher(env.NEXART_RECORD_CERTIFICATION_CONFIG, writeConfig(env).apiKey).publish;
|
|
43
|
+
}
|
|
44
|
+
if (result.enabled && env.NEXART_RECORD_CUSTODY_CONFIG) {
|
|
45
|
+
try {
|
|
46
|
+
ownerDirectory(dirname(env.NEXART_RECORD_CUSTODY_CONFIG));
|
|
47
|
+
const { version: _, ...custody } = custodyConfig.parse(readOwnerInput(env.NEXART_RECORD_CUSTODY_CONFIG));
|
|
48
|
+
result.custody = custody;
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
custodySetupDiagnostics.set(result, error?.code === 'ENOENT' ? 'CUSTODY_CONFIG_MISSING' : 'CUSTODY_CONFIG_INVALID');
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
56
|
+
export function registerRecordingTool(server, config = recordingConfig()) {
|
|
57
|
+
if (!config.enabled)
|
|
58
|
+
return;
|
|
59
|
+
server.registerTool('nexart_record_execution', {
|
|
60
|
+
description: 'Record producer-supplied execution data as confidential AI V2 with encrypted recovery custody, or verify an unchanged existing confidential AI V2 CER. Node/public is the default intent. Automatic submission requires customer-configured API key, explicit delegation consent and disclosure policy; may consume quota. Missing setup is reported, never silently falls back. Explicit private and local-only supported. Does not observe all host interactions or authenticate a provider call. No openings or plaintext returned. No automatic POST retries.',
|
|
61
|
+
inputSchema: recordDiscoveryInput, outputSchema: recordOutput,
|
|
62
|
+
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: Boolean(config.publish) },
|
|
63
|
+
}, async (args) => {
|
|
64
|
+
// Discovery optionality never authorizes a partial or mixed branch.
|
|
65
|
+
// Validate before reading runtime custody or calling any recording path.
|
|
66
|
+
const parsed = mcpRecordInput.safeParse(args);
|
|
67
|
+
if (!parsed.success)
|
|
68
|
+
return {
|
|
69
|
+
isError: true, content: [{ type: 'text', text: 'INVALID_RECORDING_ARGUMENTS' }],
|
|
70
|
+
};
|
|
71
|
+
// Only explicitly configured customer delegation; never tool-controlled policy.
|
|
72
|
+
const result = await recordExecution(parsed.data, {
|
|
73
|
+
captureSource: 'producer_supplied', ...(config.custody ? { encryptedCustody: config.custody } : {}),
|
|
74
|
+
...(config.publish ? { publish: config.publish } : {}),
|
|
75
|
+
});
|
|
76
|
+
const diagnostic = result.reasonCode === 'APPROVED_CUSTODY_REQUIRED'
|
|
77
|
+
? custodySetupDiagnostics.get(config) ?? 'CUSTODY_CONFIG_MISSING' : result.reasonCode;
|
|
78
|
+
const guidance = SETUP_MESSAGES[diagnostic];
|
|
79
|
+
return { content: [
|
|
80
|
+
{ type: 'text', text: JSON.stringify(result) },
|
|
81
|
+
...(guidance ? [{ type: 'text', text: `${diagnostic}: ${guidance}` }] : []),
|
|
82
|
+
], structuredContent: result };
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=record-tools.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { recoverEncrypted } from './owner/custody.js';
|
|
3
|
+
try {
|
|
4
|
+
const [directory, identityFile, ageExecutable, ...extra] = process.argv.slice(2);
|
|
5
|
+
if (!directory || !identityFile || !ageExecutable || extra.length)
|
|
6
|
+
throw Error('USAGE');
|
|
7
|
+
process.stdout.write(JSON.stringify(recoverEncrypted(directory, identityFile, ageExecutable)) + '\n');
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
process.stderr.write('OWNER_RECOVERY_FAILED: use an isolated owner session, original committed custody directory, private identity and absolute age executable. No decrypted content returned.\n');
|
|
11
|
+
process.exitCode = 1;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=recover-confidential.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ToolName, VerificationOutput } from './contracts.js';
|
|
2
|
+
import type { SdkOutcome } from './adapters.js';
|
|
3
|
+
export declare function baseOutput(tool: ToolName, bundle: unknown): VerificationOutput;
|
|
4
|
+
/**
|
|
5
|
+
* Deliberate disclosure allowlist, not an arbitrary result serializer.
|
|
6
|
+
* The scoped SDK `ok` remains exact; it is not Node authenticity or completeness.
|
|
7
|
+
*/
|
|
8
|
+
export declare function projectSdkResult(raw: SdkOutcome): Record<string, unknown>;
|