@nexart/mcp-server 0.0.0-stage → 0.2.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.
Files changed (100) hide show
  1. package/CHANGELOG.md +108 -0
  2. package/CONTRIBUTING.md +58 -0
  3. package/LICENSE +202 -0
  4. package/NOTICE +14 -0
  5. package/README.md +356 -2
  6. package/SECURITY.md +77 -0
  7. package/THIRD_PARTY_NOTICES.md +111 -0
  8. package/dist/adapters.d.ts +16 -0
  9. package/dist/adapters.js +48 -0
  10. package/dist/approve-public.d.ts +2 -0
  11. package/dist/approve-public.js +65 -0
  12. package/dist/contracts.d.ts +48 -0
  13. package/dist/contracts.js +35 -0
  14. package/dist/create-confidential.d.ts +2 -0
  15. package/dist/create-confidential.js +34 -0
  16. package/dist/instrumentation/openai-worker.d.ts +1 -0
  17. package/dist/instrumentation/openai-worker.js +26 -0
  18. package/dist/instrumentation/openai.d.ts +51 -0
  19. package/dist/instrumentation/openai.js +197 -0
  20. package/dist/json-schema.d.ts +9 -0
  21. package/dist/json-schema.js +20 -0
  22. package/dist/limits.d.ts +15 -0
  23. package/dist/limits.js +62 -0
  24. package/dist/lookup/contracts.d.ts +38 -0
  25. package/dist/lookup/contracts.js +23 -0
  26. package/dist/lookup/verify.d.ts +54 -0
  27. package/dist/lookup/verify.js +110 -0
  28. package/dist/network/client.d.ts +26 -0
  29. package/dist/network/client.js +188 -0
  30. package/dist/network/contracts.d.ts +104 -0
  31. package/dist/network/contracts.js +54 -0
  32. package/dist/network-tools.d.ts +5 -0
  33. package/dist/network-tools.js +32 -0
  34. package/dist/owner/create.d.ts +52 -0
  35. package/dist/owner/create.js +117 -0
  36. package/dist/owner/custody.d.ts +36 -0
  37. package/dist/owner/custody.js +210 -0
  38. package/dist/owner/host.d.ts +10 -0
  39. package/dist/owner/host.js +70 -0
  40. package/dist/owner/publisher.d.ts +21 -0
  41. package/dist/owner/publisher.js +27 -0
  42. package/dist/owner/reconcile.d.ts +16 -0
  43. package/dist/owner/reconcile.js +109 -0
  44. package/dist/protocol-safety.d.ts +3 -0
  45. package/dist/protocol-safety.js +16 -0
  46. package/dist/receipts/contracts.d.ts +72 -0
  47. package/dist/receipts/contracts.js +34 -0
  48. package/dist/receipts/verify.d.ts +4 -0
  49. package/dist/receipts/verify.js +104 -0
  50. package/dist/record/contracts.d.ts +323 -0
  51. package/dist/record/contracts.js +75 -0
  52. package/dist/record/customer.d.ts +40 -0
  53. package/dist/record/customer.js +99 -0
  54. package/dist/record/policy.d.ts +46 -0
  55. package/dist/record/policy.js +67 -0
  56. package/dist/record/publication.d.ts +23 -0
  57. package/dist/record/publication.js +148 -0
  58. package/dist/record/record.d.ts +15 -0
  59. package/dist/record/record.js +97 -0
  60. package/dist/record/state.d.ts +44 -0
  61. package/dist/record/state.js +84 -0
  62. package/dist/record-tools.d.ts +13 -0
  63. package/dist/record-tools.js +95 -0
  64. package/dist/recover-confidential.d.ts +2 -0
  65. package/dist/recover-confidential.js +13 -0
  66. package/dist/results.d.ts +8 -0
  67. package/dist/results.js +83 -0
  68. package/dist/server.d.ts +12 -0
  69. package/dist/server.js +39 -0
  70. package/dist/stdio.d.ts +2 -0
  71. package/dist/stdio.js +88 -0
  72. package/dist/trust/lifecycle.d.ts +13 -0
  73. package/dist/trust/lifecycle.js +42 -0
  74. package/dist/trust/policy.d.ts +14 -0
  75. package/dist/trust/policy.js +6 -0
  76. package/dist/verify.d.ts +3 -0
  77. package/dist/verify.js +56 -0
  78. package/dist/write/approval.d.ts +5 -0
  79. package/dist/write/approval.js +95 -0
  80. package/dist/write/attest.d.ts +17 -0
  81. package/dist/write/attest.js +141 -0
  82. package/dist/write/config.d.ts +11 -0
  83. package/dist/write/config.js +12 -0
  84. package/dist/write/contracts.d.ts +229 -0
  85. package/dist/write/contracts.js +61 -0
  86. package/dist/write/post.d.ts +11 -0
  87. package/dist/write/post.js +105 -0
  88. package/dist/write/profile.d.ts +19 -0
  89. package/dist/write/profile.js +114 -0
  90. package/dist/write/seal.d.ts +3 -0
  91. package/dist/write/seal.js +49 -0
  92. package/dist/write-tools.d.ts +4 -0
  93. package/dist/write-tools.js +36 -0
  94. package/docs/consumer-guide.md +133 -0
  95. package/docs/examples/customer-claude-desktop.json +14 -0
  96. package/docs/examples/customer-consent.json +15 -0
  97. package/docs/examples/customer-custody.json +8 -0
  98. package/docs/examples/customer-policy.json +43 -0
  99. package/package.json +58 -4
  100. package/server.json +20 -0
@@ -0,0 +1,72 @@
1
+ import * as z from 'zod/v4';
2
+ export declare const RECEIPT_TOOL: "nexart_verify_node_receipt";
3
+ export declare const receiptSchema: z.ZodObject<{
4
+ receiptVersion: z.ZodLiteral<"attestation.receipt.v1">;
5
+ attestationId: z.ZodString;
6
+ certificateHash: z.ZodString;
7
+ nodeRuntimeHash: z.ZodString;
8
+ protocolVersion: z.ZodEnum<{
9
+ "1.2.0": "1.2.0";
10
+ "1.3.0": "1.3.0";
11
+ "1.3.1": "1.3.1";
12
+ }>;
13
+ nodeId: z.ZodString;
14
+ attestorKeyId: z.ZodString;
15
+ attestedAt: z.ZodOptional<z.ZodString>;
16
+ timestampType: z.ZodOptional<z.ZodString>;
17
+ timestampStatus: z.ZodOptional<z.ZodString>;
18
+ timestampProvider: z.ZodOptional<z.ZodString>;
19
+ }, z.core.$strict>;
20
+ export declare const receiptInput: z.ZodObject<{
21
+ source: z.ZodEnum<{
22
+ inline: "inline";
23
+ public_lookup: "public_lookup";
24
+ }>;
25
+ certificateHash: z.ZodString;
26
+ receipt: z.ZodOptional<z.ZodUnknown>;
27
+ signatureB64Url: z.ZodOptional<z.ZodString>;
28
+ }, z.core.$strict>;
29
+ export declare const receiptOutput: z.ZodObject<{
30
+ contractVersion: z.ZodLiteral<"1">;
31
+ reasonCode: z.ZodString;
32
+ signature: z.ZodEnum<{
33
+ valid: "valid";
34
+ invalid: "invalid";
35
+ not_performed: "not_performed";
36
+ }>;
37
+ hashBinding: z.ZodEnum<{
38
+ not_performed: "not_performed";
39
+ match: "match";
40
+ mismatch: "mismatch";
41
+ }>;
42
+ nodeIdentity: z.ZodEnum<{
43
+ not_established: "not_established";
44
+ match: "match";
45
+ mismatch: "mismatch";
46
+ }>;
47
+ keyStatus: z.ZodEnum<{
48
+ deprecated: "deprecated";
49
+ unknown: "unknown";
50
+ active: "active";
51
+ revoked: "revoked";
52
+ unavailable: "unavailable";
53
+ }>;
54
+ keyLifecycle: z.ZodEnum<{
55
+ unknown: "unknown";
56
+ valid: "valid";
57
+ invalid: "invalid";
58
+ }>;
59
+ lifecycleCode: z.ZodString;
60
+ signerTrust: z.ZodEnum<{
61
+ not_established: "not_established";
62
+ trusted_under_policy: "trusted_under_policy";
63
+ rejected: "rejected";
64
+ }>;
65
+ artifactIntegrity: z.ZodLiteral<"not_performed">;
66
+ sdk: z.ZodNullable<z.ZodObject<{
67
+ ok: z.ZodBoolean;
68
+ code: z.ZodString;
69
+ }, z.core.$strict>>;
70
+ limitations: z.ZodArray<z.ZodString>;
71
+ }, z.core.$strict>;
72
+ export type ReceiptOutput = z.infer<typeof receiptOutput>;
@@ -0,0 +1,34 @@
1
+ import * as z from 'zod/v4';
2
+ import { anyJsonValue } from '../json-schema.js';
3
+ import { boundedString, hashSchema } from '../network/contracts.js';
4
+ export const RECEIPT_TOOL = 'nexart_verify_node_receipt';
5
+ export const receiptSchema = z.strictObject({
6
+ receiptVersion: z.literal('attestation.receipt.v1'),
7
+ attestationId: boundedString, certificateHash: hashSchema, nodeRuntimeHash: hashSchema,
8
+ protocolVersion: z.enum(['1.2.0', '1.3.0', '1.3.1']),
9
+ nodeId: boundedString, attestorKeyId: boundedString,
10
+ attestedAt: z.string().max(64).optional(),
11
+ timestampType: boundedString.optional(), timestampStatus: boundedString.optional(),
12
+ timestampProvider: boundedString.optional(),
13
+ });
14
+ // Receipt remains unknown at the MCP boundary so unsupported versions have explicit outcomes.
15
+ export const receiptInput = z.strictObject({
16
+ source: z.enum(['inline', 'public_lookup']),
17
+ certificateHash: hashSchema,
18
+ receipt: anyJsonValue.optional(),
19
+ signatureB64Url: z.string().min(1).max(128).optional(),
20
+ });
21
+ export const receiptOutput = z.strictObject({
22
+ contractVersion: z.literal('1'), reasonCode: z.string().max(96),
23
+ signature: z.enum(['valid', 'invalid', 'not_performed']),
24
+ hashBinding: z.enum(['match', 'mismatch', 'not_performed']),
25
+ nodeIdentity: z.enum(['match', 'mismatch', 'not_established']),
26
+ keyStatus: z.enum(['active', 'deprecated', 'revoked', 'unknown', 'unavailable']),
27
+ keyLifecycle: z.enum(['valid', 'invalid', 'unknown']),
28
+ lifecycleCode: z.string().max(96),
29
+ signerTrust: z.enum(['trusted_under_policy', 'rejected', 'not_established']),
30
+ artifactIntegrity: z.literal('not_performed'),
31
+ sdk: z.strictObject({ ok: z.boolean(), code: z.string().max(96) }).nullable(),
32
+ limitations: z.array(z.string().max(256)).max(12),
33
+ });
34
+ //# sourceMappingURL=contracts.js.map
@@ -0,0 +1,4 @@
1
+ import { NodeNetwork } from '../network/client.js';
2
+ import { type TrustPolicy } from '../trust/policy.js';
3
+ import { type ReceiptOutput } from './contracts.js';
4
+ export declare function verifyReceipt(args: unknown, network: NodeNetwork, policy?: TrustPolicy, signal?: AbortSignal): Promise<ReceiptOutput>;
@@ -0,0 +1,104 @@
1
+ import { selectNodeKey, verifyNodeReceiptSignature, } from '@nexart/ai-execution';
2
+ import { checkInput, isObject } from '../limits.js';
3
+ import { NETWORK_LIMITS, NodeNetwork, safeFailure } from '../network/client.js';
4
+ import { manifestSchema, parseResponse } from '../network/contracts.js';
5
+ import { resolveCer } from '../lookup/verify.js';
6
+ import { TRUST_POLICY } from '../trust/policy.js';
7
+ import { lifecycle } from '../trust/lifecycle.js';
8
+ import { receiptInput, receiptSchema } from './contracts.js';
9
+ export async function verifyReceipt(args, network, policy = TRUST_POLICY, signal) {
10
+ const output = {
11
+ contractVersion: '1', reasonCode: 'INVALID_ARGUMENTS', signature: 'not_performed',
12
+ hashBinding: 'not_performed', nodeIdentity: 'not_established', keyStatus: 'unavailable',
13
+ keyLifecycle: 'unknown', lifecycleCode: 'NOT_PERFORMED', signerTrust: 'not_established',
14
+ artifactIntegrity: 'not_performed', sdk: null,
15
+ limitations: [
16
+ 'Signature validity does not establish signer trust, artifact integrity or execution truth.',
17
+ 'No approved production key pins or historical exceptions are supplied by default.',
18
+ 'Node-issued receipt time is not independently trusted time or RFC 3161 verification.',
19
+ 'A current key manifest is not an authenticated historical key archive.',
20
+ ],
21
+ };
22
+ const limit = checkInput(args);
23
+ if (limit)
24
+ return { ...output, reasonCode: limit };
25
+ if (Buffer.byteLength(JSON.stringify(args)) > NETWORK_LIMITS.receiptBytes) {
26
+ return { ...output, reasonCode: 'INPUT_TOO_LARGE' };
27
+ }
28
+ const parsed = receiptInput.safeParse(args);
29
+ if (!parsed.success)
30
+ return output;
31
+ const input = parsed.data;
32
+ if ((input.source === 'inline' && (!input.receipt || !input.signatureB64Url)) ||
33
+ (input.source === 'public_lookup' && (Object.hasOwn(input, 'receipt') || Object.hasOwn(input, 'signatureB64Url')))) {
34
+ return output;
35
+ }
36
+ try {
37
+ return await network.run(signal, async (active) => {
38
+ let candidate = input.receipt, signature = input.signatureB64Url;
39
+ if (input.source === 'public_lookup') {
40
+ const resolved = await resolveCer(input.certificateHash, network, active);
41
+ candidate = resolved.verification.receipt;
42
+ signature = resolved.verification.receiptSignature;
43
+ }
44
+ if (isObject(candidate) && candidate.receiptVersion !== 'attestation.receipt.v1') {
45
+ return { ...output, reasonCode: 'UNSUPPORTED_RECEIPT_VERSION' };
46
+ }
47
+ const parsedReceipt = receiptSchema.safeParse(candidate);
48
+ if (!parsedReceipt.success || !signature)
49
+ return { ...output, reasonCode: 'INVALID_RECEIPT' };
50
+ // Strict validation accepts every current signed field; pass the complete original object.
51
+ const receipt = parsedReceipt.data;
52
+ output.hashBinding = receipt.certificateHash === input.certificateHash ? 'match' : 'mismatch';
53
+ output.nodeIdentity = receipt.nodeId === policy.expectedNodeId ? 'match' : 'mismatch';
54
+ const manifest = parseResponse(manifestSchema, await network.json('/.well-known/nexart-node.json', active, true));
55
+ if (manifest.nodeId !== policy.expectedNodeId) {
56
+ return { ...output, signerTrust: 'rejected', reasonCode: 'MANIFEST_NODE_ID_MISMATCH' };
57
+ }
58
+ const kids = manifest.keys.map(key => key.kid);
59
+ if (new Set(kids).size !== kids.length)
60
+ return { ...output, reasonCode: 'AMBIGUOUS_KEY_ID' };
61
+ const selected = selectNodeKey(manifest, receipt.attestorKeyId);
62
+ if (selected.error)
63
+ return { ...output, keyStatus: 'unknown', reasonCode: selected.error.code };
64
+ const key = selected.key;
65
+ const entry = manifest.keys.find(item => item.kid === receipt.attestorKeyId);
66
+ output.keyStatus = entry.revoked ? 'revoked' : entry.status ?? 'unknown';
67
+ const publicKey = entry.publicKeyJwk?.x ?? entry.publicKey;
68
+ const matchingPins = policy.pins.filter(pin => pin.kid === receipt.attestorKeyId);
69
+ const pin = matchingPins.length === 1 && matchingPins[0].publicKeyB64Url === publicKey
70
+ ? matchingPins[0] : undefined;
71
+ const sig = await verifyNodeReceiptSignature({
72
+ receipt: candidate, signatureB64Url: signature,
73
+ key: key.publicKeyJwk ? { jwk: key.publicKeyJwk }
74
+ : key.publicKey ? { rawB64Url: key.publicKey }
75
+ : key.publicKeySpkiB64 ? { spkiB64: key.publicKeySpkiB64 } : {},
76
+ });
77
+ active.throwIfAborted();
78
+ output.sdk = { ok: sig.ok, code: sig.code };
79
+ output.signature = sig.ok ? 'valid' : 'invalid';
80
+ const life = lifecycle(entry, receipt.attestedAt, pin);
81
+ output.keyLifecycle = life.state;
82
+ output.lifecycleCode = life.code;
83
+ if (!sig.ok)
84
+ return { ...output, reasonCode: sig.code, signerTrust: 'rejected' };
85
+ if (output.hashBinding !== 'match')
86
+ return { ...output, reasonCode: 'CERTIFICATE_HASH_MISMATCH', signerTrust: 'rejected' };
87
+ if (output.nodeIdentity !== 'match')
88
+ return { ...output, reasonCode: 'NODE_ID_MISMATCH', signerTrust: 'rejected' };
89
+ if (life.state === 'invalid')
90
+ return { ...output, reasonCode: life.code, signerTrust: 'rejected' };
91
+ if (matchingPins.length > 1)
92
+ return { ...output, reasonCode: 'AMBIGUOUS_TRUST_PIN' };
93
+ if (!pin)
94
+ return { ...output, reasonCode: matchingPins.length ? 'PIN_MISMATCH' : 'UNAPPROVED_KEY' };
95
+ if (life.state !== 'valid')
96
+ return { ...output, reasonCode: life.code };
97
+ return { ...output, reasonCode: 'OK', signerTrust: 'trusted_under_policy' };
98
+ });
99
+ }
100
+ catch (error) {
101
+ return { ...output, reasonCode: safeFailure(error), signerTrust: 'not_established' };
102
+ }
103
+ }
104
+ //# sourceMappingURL=verify.js.map
@@ -0,0 +1,323 @@
1
+ import * as z from 'zod/v4';
2
+ export declare const receiptProofSchema: z.ZodObject<{
3
+ receipt: z.ZodObject<{
4
+ receiptVersion: z.ZodLiteral<"attestation.receipt.v1">;
5
+ attestationId: z.ZodString;
6
+ certificateHash: z.ZodString;
7
+ nodeRuntimeHash: z.ZodString;
8
+ protocolVersion: z.ZodEnum<{
9
+ "1.2.0": "1.2.0";
10
+ "1.3.0": "1.3.0";
11
+ "1.3.1": "1.3.1";
12
+ }>;
13
+ nodeId: z.ZodString;
14
+ attestorKeyId: z.ZodString;
15
+ attestedAt: z.ZodOptional<z.ZodString>;
16
+ timestampType: z.ZodOptional<z.ZodString>;
17
+ timestampStatus: z.ZodOptional<z.ZodString>;
18
+ timestampProvider: z.ZodOptional<z.ZodString>;
19
+ }, z.core.$strict>;
20
+ signatureB64Url: z.ZodString;
21
+ }, z.core.$strict>;
22
+ export declare const recordInput: z.ZodDiscriminatedUnion<[z.ZodObject<{
23
+ kind: z.ZodLiteral<"execution">;
24
+ execution: z.ZodRecord<z.ZodString, z.ZodUnknown>;
25
+ createdAt: z.ZodString;
26
+ certification: z.ZodOptional<z.ZodObject<{
27
+ mode: z.ZodDefault<z.ZodEnum<{
28
+ local: "local";
29
+ node: "node";
30
+ }>>;
31
+ visibility: z.ZodOptional<z.ZodEnum<{
32
+ private: "private";
33
+ public: "public";
34
+ }>>;
35
+ }, z.core.$strict>>;
36
+ }, z.core.$strict>, z.ZodObject<{
37
+ kind: z.ZodLiteral<"cer">;
38
+ bundle: z.ZodRecord<z.ZodString, z.ZodUnknown>;
39
+ certification: z.ZodOptional<z.ZodObject<{
40
+ mode: z.ZodDefault<z.ZodEnum<{
41
+ local: "local";
42
+ node: "node";
43
+ }>>;
44
+ visibility: z.ZodOptional<z.ZodEnum<{
45
+ private: "private";
46
+ public: "public";
47
+ }>>;
48
+ }, z.core.$strict>>;
49
+ }, z.core.$strict>], "kind">;
50
+ /** Strict public contract; the existing library's validation behavior is retained. */
51
+ export declare const mcpRecordInput: z.ZodDiscriminatedUnion<[z.ZodObject<{
52
+ kind: z.ZodLiteral<"execution">;
53
+ execution: z.ZodObject<{
54
+ executionId: z.ZodString;
55
+ timestamp: z.ZodString;
56
+ provider: z.ZodString;
57
+ model: z.ZodString;
58
+ input: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>]>;
59
+ output: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>]>;
60
+ parameters: z.ZodObject<{
61
+ temperature: z.ZodNumber;
62
+ maxTokens: z.ZodNumber;
63
+ topP: z.ZodNullable<z.ZodNumber>;
64
+ seed: z.ZodNullable<z.ZodNumber>;
65
+ }, z.core.$strict>;
66
+ executionRole: z.ZodEnum<{
67
+ advisory: "advisory";
68
+ operative: "operative";
69
+ unspecified: "unspecified";
70
+ }>;
71
+ instruction: z.ZodOptional<z.ZodString>;
72
+ instructionKind: z.ZodOptional<z.ZodEnum<{
73
+ system: "system";
74
+ derived: "derived";
75
+ label: "label";
76
+ }>>;
77
+ decisionRefs: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
78
+ modelEvidence: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
79
+ identity: z.ZodOptional<z.ZodObject<{
80
+ provider: z.ZodString;
81
+ sub: z.ZodString;
82
+ assertionHash: z.ZodString;
83
+ emailHash: z.ZodOptional<z.ZodString>;
84
+ verified: z.ZodBoolean;
85
+ }, z.core.$strict>>;
86
+ toolCalls: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
87
+ runId: z.ZodOptional<z.ZodString>;
88
+ stepId: z.ZodOptional<z.ZodString>;
89
+ stepIndex: z.ZodOptional<z.ZodNumber>;
90
+ workflowId: z.ZodOptional<z.ZodString>;
91
+ conversationId: z.ZodOptional<z.ZodString>;
92
+ prevStepHash: z.ZodOptional<z.ZodString>;
93
+ sdkVersion: z.ZodOptional<z.ZodString>;
94
+ appId: z.ZodOptional<z.ZodString>;
95
+ ext: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
96
+ }, z.core.$strict>;
97
+ createdAt: z.ZodString;
98
+ certification: z.ZodOptional<z.ZodObject<{
99
+ mode: z.ZodDefault<z.ZodEnum<{
100
+ local: "local";
101
+ node: "node";
102
+ }>>;
103
+ visibility: z.ZodOptional<z.ZodEnum<{
104
+ private: "private";
105
+ public: "public";
106
+ }>>;
107
+ }, z.core.$strict>>;
108
+ }, z.core.$strict>, z.ZodObject<{
109
+ kind: z.ZodLiteral<"cer">;
110
+ bundle: z.ZodObject<{
111
+ bundleType: z.ZodLiteral<"cer.ai.execution.v2">;
112
+ version: z.ZodString;
113
+ createdAt: z.ZodString;
114
+ certificateHash: z.ZodString;
115
+ snapshot: z.ZodRecord<z.ZodString, z.ZodUnknown>;
116
+ protectedSet: z.ZodRecord<z.ZodString, z.ZodUnknown>;
117
+ }, z.core.$strict>;
118
+ certification: z.ZodOptional<z.ZodObject<{
119
+ mode: z.ZodDefault<z.ZodEnum<{
120
+ local: "local";
121
+ node: "node";
122
+ }>>;
123
+ visibility: z.ZodOptional<z.ZodEnum<{
124
+ private: "private";
125
+ public: "public";
126
+ }>>;
127
+ }, z.core.$strict>>;
128
+ }, z.core.$strict>], "kind">;
129
+ /** Discovery only: some hosts discard root unions. Branch requirements remain
130
+ * authoritative in mcpRecordInput, explicitly parsed by the handler.
131
+ * Standard patterns preserve prefix-only identity semantics without Zod's
132
+ * nonstandard starts_with format. Runtime identity validation is unchanged. */
133
+ export declare const recordDiscoveryInput: z.ZodObject<{
134
+ kind: z.ZodEnum<{
135
+ cer: "cer";
136
+ execution: "execution";
137
+ }>;
138
+ execution: z.ZodOptional<z.ZodObject<{
139
+ executionId: z.ZodString;
140
+ timestamp: z.ZodString;
141
+ provider: z.ZodString;
142
+ model: z.ZodString;
143
+ input: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>]>;
144
+ output: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>]>;
145
+ parameters: z.ZodObject<{
146
+ temperature: z.ZodNumber;
147
+ maxTokens: z.ZodNumber;
148
+ topP: z.ZodNullable<z.ZodNumber>;
149
+ seed: z.ZodNullable<z.ZodNumber>;
150
+ }, z.core.$strict>;
151
+ executionRole: z.ZodEnum<{
152
+ advisory: "advisory";
153
+ operative: "operative";
154
+ unspecified: "unspecified";
155
+ }>;
156
+ instruction: z.ZodOptional<z.ZodString>;
157
+ instructionKind: z.ZodOptional<z.ZodEnum<{
158
+ system: "system";
159
+ derived: "derived";
160
+ label: "label";
161
+ }>>;
162
+ decisionRefs: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
163
+ modelEvidence: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
164
+ toolCalls: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
165
+ runId: z.ZodOptional<z.ZodString>;
166
+ stepId: z.ZodOptional<z.ZodString>;
167
+ stepIndex: z.ZodOptional<z.ZodNumber>;
168
+ workflowId: z.ZodOptional<z.ZodString>;
169
+ conversationId: z.ZodOptional<z.ZodString>;
170
+ prevStepHash: z.ZodOptional<z.ZodString>;
171
+ sdkVersion: z.ZodOptional<z.ZodString>;
172
+ appId: z.ZodOptional<z.ZodString>;
173
+ ext: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
174
+ identity: z.ZodOptional<z.ZodObject<{
175
+ provider: z.ZodString;
176
+ sub: z.ZodString;
177
+ verified: z.ZodBoolean;
178
+ assertionHash: z.ZodString;
179
+ emailHash: z.ZodOptional<z.ZodString>;
180
+ }, z.core.$strict>>;
181
+ }, z.core.$strict>>;
182
+ bundle: z.ZodOptional<z.ZodObject<{
183
+ bundleType: z.ZodLiteral<"cer.ai.execution.v2">;
184
+ version: z.ZodString;
185
+ createdAt: z.ZodString;
186
+ certificateHash: z.ZodString;
187
+ snapshot: z.ZodRecord<z.ZodString, z.ZodUnknown>;
188
+ protectedSet: z.ZodRecord<z.ZodString, z.ZodUnknown>;
189
+ }, z.core.$strict>>;
190
+ createdAt: z.ZodOptional<z.ZodString>;
191
+ certification: z.ZodOptional<z.ZodObject<{
192
+ mode: z.ZodDefault<z.ZodEnum<{
193
+ local: "local";
194
+ node: "node";
195
+ }>>;
196
+ visibility: z.ZodOptional<z.ZodEnum<{
197
+ private: "private";
198
+ public: "public";
199
+ }>>;
200
+ }, z.core.$strict>>;
201
+ }, z.core.$strict>;
202
+ export type CaptureSource = 'producer_supplied' | 'instrumented_provider_call';
203
+ export interface RecordResult {
204
+ /** Hosted-only additive proof; never contains recovery openings. */
205
+ receiptProof?: z.infer<typeof receiptProofSchema>;
206
+ contractVersion: '1';
207
+ captureProvenance: CaptureSource;
208
+ evidence: 'not_created' | 'created_confidential' | 'existing_unchanged' | 'custody_failed' | 'invalid';
209
+ custody: 'not_performed' | 'unencrypted_owner_approved' | 'encrypted_owner_recipient' | 'external_existing_cer';
210
+ localIntegrity: 'valid' | 'invalid' | 'not_performed';
211
+ certificationIntent: 'node' | 'local';
212
+ policyAuthorization: 'not_required' | 'setup_required' | 'authorization_denied' | 'policy_authorized';
213
+ submission: 'not_sent' | 'rejected' | 'node_reported_accepted' | 'outcome_unknown';
214
+ requestedVisibility: 'public' | 'private' | null;
215
+ nodeConfirmedVisibility: 'public' | 'private' | null;
216
+ certificateHash: string | null;
217
+ receiptSignature: string;
218
+ hashBinding: string;
219
+ signerTrust: string;
220
+ reasonCode: string;
221
+ usage: {
222
+ authoritative: false;
223
+ accountRemaining: null;
224
+ scope: 'publisher_local';
225
+ reservedAttempts: number | null;
226
+ };
227
+ }
228
+ export declare const recordOutput: z.ZodObject<{
229
+ receiptProof: z.ZodOptional<z.ZodObject<{
230
+ receipt: z.ZodObject<{
231
+ receiptVersion: z.ZodLiteral<"attestation.receipt.v1">;
232
+ attestationId: z.ZodString;
233
+ certificateHash: z.ZodString;
234
+ nodeRuntimeHash: z.ZodString;
235
+ protocolVersion: z.ZodEnum<{
236
+ "1.2.0": "1.2.0";
237
+ "1.3.0": "1.3.0";
238
+ "1.3.1": "1.3.1";
239
+ }>;
240
+ nodeId: z.ZodString;
241
+ attestorKeyId: z.ZodString;
242
+ attestedAt: z.ZodOptional<z.ZodString>;
243
+ timestampType: z.ZodOptional<z.ZodString>;
244
+ timestampStatus: z.ZodOptional<z.ZodString>;
245
+ timestampProvider: z.ZodOptional<z.ZodString>;
246
+ }, z.core.$strict>;
247
+ signatureB64Url: z.ZodString;
248
+ }, z.core.$strict>>;
249
+ contractVersion: z.ZodLiteral<"1">;
250
+ captureProvenance: z.ZodEnum<{
251
+ producer_supplied: "producer_supplied";
252
+ instrumented_provider_call: "instrumented_provider_call";
253
+ }>;
254
+ evidence: z.ZodEnum<{
255
+ invalid: "invalid";
256
+ not_created: "not_created";
257
+ created_confidential: "created_confidential";
258
+ existing_unchanged: "existing_unchanged";
259
+ custody_failed: "custody_failed";
260
+ }>;
261
+ custody: z.ZodEnum<{
262
+ not_performed: "not_performed";
263
+ encrypted_owner_recipient: "encrypted_owner_recipient";
264
+ unencrypted_owner_approved: "unencrypted_owner_approved";
265
+ external_existing_cer: "external_existing_cer";
266
+ }>;
267
+ localIntegrity: z.ZodEnum<{
268
+ valid: "valid";
269
+ invalid: "invalid";
270
+ not_performed: "not_performed";
271
+ }>;
272
+ certificationIntent: z.ZodEnum<{
273
+ local: "local";
274
+ node: "node";
275
+ }>;
276
+ policyAuthorization: z.ZodEnum<{
277
+ not_required: "not_required";
278
+ setup_required: "setup_required";
279
+ authorization_denied: "authorization_denied";
280
+ policy_authorized: "policy_authorized";
281
+ }>;
282
+ submission: z.ZodEnum<{
283
+ rejected: "rejected";
284
+ not_sent: "not_sent";
285
+ node_reported_accepted: "node_reported_accepted";
286
+ outcome_unknown: "outcome_unknown";
287
+ }>;
288
+ requestedVisibility: z.ZodNullable<z.ZodEnum<{
289
+ private: "private";
290
+ public: "public";
291
+ }>>;
292
+ nodeConfirmedVisibility: z.ZodNullable<z.ZodEnum<{
293
+ private: "private";
294
+ public: "public";
295
+ }>>;
296
+ certificateHash: z.ZodNullable<z.ZodString>;
297
+ receiptSignature: z.ZodString;
298
+ hashBinding: z.ZodString;
299
+ signerTrust: z.ZodString;
300
+ reasonCode: z.ZodString;
301
+ usage: z.ZodObject<{
302
+ authoritative: z.ZodLiteral<false>;
303
+ accountRemaining: z.ZodNull;
304
+ scope: z.ZodLiteral<"publisher_local">;
305
+ reservedAttempts: z.ZodNullable<z.ZodNumber>;
306
+ }, z.core.$strict>;
307
+ }, z.core.$strict>;
308
+ export interface PreparedRecord {
309
+ body: string;
310
+ certificateHash: string;
311
+ visibility: 'public' | 'private';
312
+ captureSource: CaptureSource;
313
+ }
314
+ export interface PublicationResult {
315
+ authorization: 'setup_required' | 'authorization_denied' | 'policy_authorized';
316
+ submission: RecordResult['submission'];
317
+ nodeConfirmedVisibility: RecordResult['nodeConfirmedVisibility'];
318
+ reasonCode: string;
319
+ receiptSignature: string;
320
+ hashBinding: string;
321
+ signerTrust: string;
322
+ reservedAttempts: number | null;
323
+ }
@@ -0,0 +1,75 @@
1
+ import * as z from 'zod/v4';
2
+ import { executionSchema, identitySchema } from '../write/contracts.js';
3
+ import { hashSchema } from '../network/contracts.js';
4
+ import { receiptSchema } from '../receipts/contracts.js';
5
+ export const receiptProofSchema = z.strictObject({
6
+ receipt: receiptSchema, signatureB64Url: z.string().regex(/^[A-Za-z0-9_-]{86}$/),
7
+ });
8
+ const certification = z.strictObject({
9
+ mode: z.enum(['node', 'local']).default('node'),
10
+ visibility: z.enum(['public', 'private']).optional(),
11
+ }).superRefine((v, ctx) => {
12
+ if (v.mode === 'local' && v.visibility !== undefined)
13
+ ctx.addIssue({ code: 'custom', message: 'Local mode has no Node visibility' });
14
+ });
15
+ export const recordInput = z.discriminatedUnion('kind', [
16
+ z.strictObject({
17
+ kind: z.literal('execution'), execution: z.record(z.string(), z.unknown()),
18
+ createdAt: z.string().min(1), certification: certification.optional(),
19
+ }),
20
+ z.strictObject({
21
+ kind: z.literal('cer'), bundle: z.record(z.string(), z.unknown()),
22
+ certification: certification.optional(),
23
+ }),
24
+ ]);
25
+ /** Strict public contract; the existing library's validation behavior is retained. */
26
+ export const mcpRecordInput = z.discriminatedUnion('kind', [
27
+ z.strictObject({
28
+ kind: z.literal('execution'), execution: executionSchema,
29
+ createdAt: z.string().min(1), certification: certification.optional(),
30
+ }),
31
+ z.strictObject({
32
+ kind: z.literal('cer'), bundle: z.strictObject({
33
+ bundleType: z.literal('cer.ai.execution.v2'), version: z.string(),
34
+ createdAt: z.string(), certificateHash: hashSchema,
35
+ snapshot: z.record(z.string(), z.unknown()), protectedSet: z.record(z.string(), z.unknown()),
36
+ }),
37
+ certification: certification.optional(),
38
+ }),
39
+ ]);
40
+ /** Discovery only: some hosts discard root unions. Branch requirements remain
41
+ * authoritative in mcpRecordInput, explicitly parsed by the handler.
42
+ * Standard patterns preserve prefix-only identity semantics without Zod's
43
+ * nonstandard starts_with format. Runtime identity validation is unchanged. */
44
+ export const recordDiscoveryInput = z.strictObject({
45
+ kind: z.enum(['execution', 'cer']),
46
+ execution: executionSchema.extend({
47
+ identity: identitySchema.extend({
48
+ assertionHash: z.string().regex(/^sha256:/),
49
+ emailHash: z.string().regex(/^sha256:/).optional(),
50
+ }).optional(),
51
+ }).optional(),
52
+ bundle: mcpRecordInput.options[1].shape.bundle.optional(),
53
+ createdAt: mcpRecordInput.options[0].shape.createdAt.optional(),
54
+ certification: certification.optional(),
55
+ });
56
+ export const recordOutput = z.strictObject({
57
+ receiptProof: receiptProofSchema.optional(),
58
+ contractVersion: z.literal('1'),
59
+ captureProvenance: z.enum(['producer_supplied', 'instrumented_provider_call']),
60
+ evidence: z.enum(['not_created', 'created_confidential', 'existing_unchanged', 'custody_failed', 'invalid']),
61
+ custody: z.enum(['not_performed', 'unencrypted_owner_approved', 'encrypted_owner_recipient', 'external_existing_cer']),
62
+ localIntegrity: z.enum(['valid', 'invalid', 'not_performed']),
63
+ certificationIntent: z.enum(['node', 'local']),
64
+ policyAuthorization: z.enum(['not_required', 'setup_required', 'authorization_denied', 'policy_authorized']),
65
+ submission: z.enum(['not_sent', 'rejected', 'node_reported_accepted', 'outcome_unknown']),
66
+ requestedVisibility: z.enum(['public', 'private']).nullable(),
67
+ nodeConfirmedVisibility: z.enum(['public', 'private']).nullable(),
68
+ certificateHash: hashSchema.nullable(), receiptSignature: z.string().max(96),
69
+ hashBinding: z.string().max(96), signerTrust: z.string().max(96), reasonCode: z.string().max(96),
70
+ usage: z.strictObject({
71
+ authoritative: z.literal(false), accountRemaining: z.null(), scope: z.literal('publisher_local'),
72
+ reservedAttempts: z.number().int().nonnegative().nullable(),
73
+ }),
74
+ });
75
+ //# sourceMappingURL=contracts.js.map
@@ -0,0 +1,40 @@
1
+ import * as z from 'zod/v4';
2
+ import type { AttestDependencies } from '../write/attest.js';
3
+ import type { PreparedRecord, PublicationResult } from './contracts.js';
4
+ /** Local operator assertions, not protection from a same-UID agent. */
5
+ export declare const customerConsent: z.ZodObject<{
6
+ version: z.ZodLiteral<1>;
7
+ mode: z.ZodLiteral<"customer_delegated">;
8
+ enabled: z.ZodBoolean;
9
+ automaticNodeSubmissions: z.ZodBoolean;
10
+ publicDisclosureAcknowledged: z.ZodBoolean;
11
+ quotaConsumptionAcknowledged: z.ZodBoolean;
12
+ revoked: z.ZodBoolean;
13
+ expiresAt: z.ZodISODateTime;
14
+ accountContext: z.ZodString;
15
+ credentialContext: z.ZodString;
16
+ policyFile: z.ZodString;
17
+ stateDirectory: z.ZodString;
18
+ approvalDirectory: z.ZodString;
19
+ }, z.core.$strict>;
20
+ export type CustomerConsent = z.infer<typeof customerConsent>;
21
+ /** Explicit customer delegation. No Mac isolation claim and no credential
22
+ * discovery beyond the established NEXART_NODE_API_KEY callback.
23
+ * Dependencies are trusted library injection only, never MCP input or env. */
24
+ export declare function createCustomerPublisher(consentFile: string, credential?: () => string | undefined, dependencies?: AttestDependencies): Readonly<{
25
+ publish(record: PreparedRecord): Promise<PublicationResult>;
26
+ /** Owner-invoked GET only; not exposed as a model-controlled MCP tool. */
27
+ reconcile(certificateHash: string, request?: typeof fetch): Promise<{
28
+ state: string;
29
+ certificateHash: string;
30
+ noRetry: boolean;
31
+ nodeConfirmedVisibility: any;
32
+ receiptSignature: "valid" | "invalid" | "not_performed";
33
+ hashBinding: "not_performed" | "match" | "mismatch";
34
+ signerTrust: "not_established" | "trusted_under_policy" | "rejected";
35
+ } | {
36
+ state: string;
37
+ certificateHash: string;
38
+ noRetry: boolean;
39
+ }>;
40
+ }>;