@proofai/sdk 1.0.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/README.md ADDED
@@ -0,0 +1,94 @@
1
+ # proofai-sdk
2
+
3
+ Cryptographic proof that AI thought before it answered.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install proofai-sdk
9
+ ```
10
+
11
+ ## Quick Start — One Line Certification
12
+
13
+ ```typescript
14
+ import { ProofAI } from 'proofai-sdk'
15
+
16
+ const proofai = new ProofAI({ apiKey: 'your-api-key' })
17
+
18
+ const cert = await proofai.certify(
19
+ 'Analyse les risques juridiques de ce contrat SaaS',
20
+ { provider: 'anthropic' }
21
+ )
22
+
23
+ console.log(cert.verified) // true
24
+ console.log(cert.bundleId) // bnd_8019b37a7f44_...
25
+ console.log(cert.bundleHash) // sha256 hash
26
+ console.log(cert.explorerUrl) // https://amoy.polygonscan.com/tx/0x...
27
+ ```
28
+
29
+ ## Step by Step
30
+
31
+ ```typescript
32
+ const proofai = new ProofAI({ apiKey: 'your-api-key' })
33
+
34
+ // 1. Compress prompt
35
+ const compressed = await proofai.compress('Your prompt here', {
36
+ compressionLevel: 'medium',
37
+ })
38
+
39
+ // 2. Execute AI
40
+ const execution = await proofai.execute(compressed.id, {
41
+ provider: 'anthropic', // 'anthropic' | 'openai' | 'gemini'
42
+ temperature: 0.7,
43
+ maxTokens: 1024,
44
+ })
45
+
46
+ // 3. Cognitive analysis
47
+ const analysis = await proofai.analyze(execution.id, execution.output)
48
+
49
+ // 4. Sign with Ed25519
50
+ const signature = await proofai.sign(execution)
51
+
52
+ // 5. Create evidence bundle
53
+ const bundle = await proofai.bundle(
54
+ compressed.id,
55
+ execution.id,
56
+ analysis.id,
57
+ signature.signatureId,
58
+ analysis.cognitiveHash,
59
+ )
60
+
61
+ // 6. Anchor to Polygon
62
+ const anchor = await proofai.anchor(bundle.id, 'polygon')
63
+
64
+ // 7. Verify
65
+ const verification = await proofai.verify(bundle.id)
66
+ console.log(verification.verified) // true
67
+ ```
68
+
69
+ ## Options
70
+
71
+ ### `certify(prompt, options?)`
72
+
73
+ | Option | Type | Default | Description |
74
+ |--------|------|---------|-------------|
75
+ | `provider` | `'anthropic' \| 'openai' \| 'gemini'` | `'anthropic'` | AI provider |
76
+ | `modelId` | `string` | auto | Model override |
77
+ | `temperature` | `number` | `0.7` | Generation temperature |
78
+ | `maxTokens` | `number` | `1024` | Max output tokens |
79
+ | `compressionLevel` | `'low' \| 'medium' \| 'high'` | `'medium'` | DSL compression level |
80
+ | `network` | `'polygon' \| 'ethereum'` | `'polygon'` | Blockchain network |
81
+ | `skipAnchor` | `boolean` | `false` | Skip blockchain anchoring |
82
+
83
+ ## Self-Hosted
84
+
85
+ ```typescript
86
+ const proofai = new ProofAI({
87
+ apiKey: 'your-supabase-anon-key',
88
+ baseUrl: 'https://your-project.supabase.co/functions/v1',
89
+ })
90
+ ```
91
+
92
+ ## License
93
+
94
+ MIT
@@ -0,0 +1,177 @@
1
+ interface ProofAIConfig {
2
+ apiKey: string;
3
+ baseUrl?: string;
4
+ }
5
+ type Provider = 'anthropic' | 'openai' | 'gemini' | 'google';
6
+ type CompressionLevel = 'low' | 'medium' | 'high';
7
+ type Network = 'polygon' | 'ethereum';
8
+ interface CompressOptions {
9
+ compressionLevel?: CompressionLevel;
10
+ preserveContext?: boolean;
11
+ targetModels?: string[];
12
+ }
13
+ interface CompressResult {
14
+ id: string;
15
+ originalPrompt: string;
16
+ compressedDsl: string;
17
+ metrics: {
18
+ originalTokens: number;
19
+ compressedTokens: number;
20
+ compressionRatio: number;
21
+ semanticLoss: number;
22
+ };
23
+ timestamp: string;
24
+ }
25
+ interface ExecuteOptions {
26
+ provider: Provider;
27
+ modelId?: string;
28
+ temperature?: number;
29
+ maxTokens?: number;
30
+ }
31
+ interface ExecuteResult {
32
+ id: string;
33
+ promptRef: string;
34
+ output: string;
35
+ metadata: {
36
+ provider: string;
37
+ model: string;
38
+ latency: number;
39
+ tokens: {
40
+ prompt: number;
41
+ completion: number;
42
+ total: number;
43
+ };
44
+ };
45
+ reasoning_trace?: Array<{
46
+ step_index: number;
47
+ type: string;
48
+ content: string;
49
+ thought_signature?: string;
50
+ }>;
51
+ trace_quality?: 'native' | 'structured' | 'inferred';
52
+ timestamp: string;
53
+ }
54
+ interface AnalyzeResult {
55
+ id: string;
56
+ executionId: string;
57
+ nodes: Array<{
58
+ id: string;
59
+ label: string;
60
+ type: string;
61
+ weight: number;
62
+ }>;
63
+ edges: Array<{
64
+ source: string;
65
+ target: string;
66
+ label: string;
67
+ weight: number;
68
+ }>;
69
+ metrics: {
70
+ nodeCount: number;
71
+ edgeCount: number;
72
+ consistencyScore: number;
73
+ complexityScore: number;
74
+ };
75
+ cognitiveHash: string;
76
+ timestamp: string;
77
+ }
78
+ interface SignResult {
79
+ signatureId: string;
80
+ signedPayload: Record<string, unknown>;
81
+ signature: {
82
+ algorithm: string;
83
+ signature: string;
84
+ signed_at: string;
85
+ signer_identity: string;
86
+ includes_thought_signatures: boolean;
87
+ };
88
+ timestampProof: {
89
+ rfc3161_timestamp: string;
90
+ verified: boolean;
91
+ } | null;
92
+ cognitive_trace?: Record<string, unknown>;
93
+ }
94
+ interface BundleResult {
95
+ id: string;
96
+ promptId: string;
97
+ executionId: string;
98
+ analysisId: string;
99
+ signatureId: string;
100
+ cognitiveHash: string;
101
+ bundleHash: string;
102
+ timeline: Array<{
103
+ event: string;
104
+ timestamp: string;
105
+ hash: string;
106
+ }>;
107
+ status: 'pending' | 'created' | 'anchored' | 'verified';
108
+ createdAt: string;
109
+ }
110
+ interface AnchorResult {
111
+ bundleId: string;
112
+ transactionHash: string;
113
+ blockNumber: number;
114
+ network: string;
115
+ explorerUrl: string;
116
+ status: 'pending' | 'confirmed' | 'failed';
117
+ timestamp: string;
118
+ }
119
+ interface VerifyResult {
120
+ bundleId: string;
121
+ verified: boolean;
122
+ checks: {
123
+ integrityValid: boolean;
124
+ timestampValid: boolean;
125
+ ledgerAnchored: boolean;
126
+ hashMatches: boolean;
127
+ };
128
+ ledgerInfo?: {
129
+ transactionHash: string;
130
+ blockNumber: number;
131
+ network: string;
132
+ confirmedAt: string;
133
+ };
134
+ timestamp: string;
135
+ }
136
+ interface CertifyOptions {
137
+ provider?: Provider;
138
+ modelId?: string;
139
+ temperature?: number;
140
+ maxTokens?: number;
141
+ compressionLevel?: CompressionLevel;
142
+ network?: Network;
143
+ skipAnchor?: boolean;
144
+ }
145
+ interface Certificate {
146
+ bundleId: string;
147
+ bundleHash: string;
148
+ verified: boolean;
149
+ explorerUrl?: string;
150
+ transactionHash?: string;
151
+ steps: {
152
+ compress: CompressResult;
153
+ execute: ExecuteResult;
154
+ analyze: AnalyzeResult;
155
+ sign: SignResult;
156
+ bundle: BundleResult;
157
+ anchor?: AnchorResult;
158
+ verify: VerifyResult;
159
+ };
160
+ }
161
+
162
+ declare class ProofAI {
163
+ private apiKey;
164
+ private baseUrl;
165
+ constructor(config: ProofAIConfig);
166
+ private call;
167
+ compress(prompt: string, options?: CompressOptions): Promise<CompressResult>;
168
+ execute(promptRef: string, options: ExecuteOptions): Promise<ExecuteResult>;
169
+ analyze(executionId: string, analysisText: string): Promise<AnalyzeResult>;
170
+ sign(execution: ExecuteResult): Promise<SignResult>;
171
+ bundle(promptId: string, executionId: string, analysisId: string, signatureId: string, cognitiveHash: string): Promise<BundleResult>;
172
+ anchor(bundleId: string, network?: 'polygon' | 'ethereum'): Promise<AnchorResult>;
173
+ verify(bundleId: string): Promise<VerifyResult>;
174
+ certify(prompt: string, options?: CertifyOptions): Promise<Certificate>;
175
+ }
176
+
177
+ export { type AnalyzeResult, type AnchorResult, type BundleResult, type Certificate, type CertifyOptions, type CompressOptions, type CompressResult, type CompressionLevel, type ExecuteOptions, type ExecuteResult, type Network, ProofAI, type ProofAIConfig, type Provider, type SignResult, type VerifyResult, ProofAI as default };
@@ -0,0 +1,177 @@
1
+ interface ProofAIConfig {
2
+ apiKey: string;
3
+ baseUrl?: string;
4
+ }
5
+ type Provider = 'anthropic' | 'openai' | 'gemini' | 'google';
6
+ type CompressionLevel = 'low' | 'medium' | 'high';
7
+ type Network = 'polygon' | 'ethereum';
8
+ interface CompressOptions {
9
+ compressionLevel?: CompressionLevel;
10
+ preserveContext?: boolean;
11
+ targetModels?: string[];
12
+ }
13
+ interface CompressResult {
14
+ id: string;
15
+ originalPrompt: string;
16
+ compressedDsl: string;
17
+ metrics: {
18
+ originalTokens: number;
19
+ compressedTokens: number;
20
+ compressionRatio: number;
21
+ semanticLoss: number;
22
+ };
23
+ timestamp: string;
24
+ }
25
+ interface ExecuteOptions {
26
+ provider: Provider;
27
+ modelId?: string;
28
+ temperature?: number;
29
+ maxTokens?: number;
30
+ }
31
+ interface ExecuteResult {
32
+ id: string;
33
+ promptRef: string;
34
+ output: string;
35
+ metadata: {
36
+ provider: string;
37
+ model: string;
38
+ latency: number;
39
+ tokens: {
40
+ prompt: number;
41
+ completion: number;
42
+ total: number;
43
+ };
44
+ };
45
+ reasoning_trace?: Array<{
46
+ step_index: number;
47
+ type: string;
48
+ content: string;
49
+ thought_signature?: string;
50
+ }>;
51
+ trace_quality?: 'native' | 'structured' | 'inferred';
52
+ timestamp: string;
53
+ }
54
+ interface AnalyzeResult {
55
+ id: string;
56
+ executionId: string;
57
+ nodes: Array<{
58
+ id: string;
59
+ label: string;
60
+ type: string;
61
+ weight: number;
62
+ }>;
63
+ edges: Array<{
64
+ source: string;
65
+ target: string;
66
+ label: string;
67
+ weight: number;
68
+ }>;
69
+ metrics: {
70
+ nodeCount: number;
71
+ edgeCount: number;
72
+ consistencyScore: number;
73
+ complexityScore: number;
74
+ };
75
+ cognitiveHash: string;
76
+ timestamp: string;
77
+ }
78
+ interface SignResult {
79
+ signatureId: string;
80
+ signedPayload: Record<string, unknown>;
81
+ signature: {
82
+ algorithm: string;
83
+ signature: string;
84
+ signed_at: string;
85
+ signer_identity: string;
86
+ includes_thought_signatures: boolean;
87
+ };
88
+ timestampProof: {
89
+ rfc3161_timestamp: string;
90
+ verified: boolean;
91
+ } | null;
92
+ cognitive_trace?: Record<string, unknown>;
93
+ }
94
+ interface BundleResult {
95
+ id: string;
96
+ promptId: string;
97
+ executionId: string;
98
+ analysisId: string;
99
+ signatureId: string;
100
+ cognitiveHash: string;
101
+ bundleHash: string;
102
+ timeline: Array<{
103
+ event: string;
104
+ timestamp: string;
105
+ hash: string;
106
+ }>;
107
+ status: 'pending' | 'created' | 'anchored' | 'verified';
108
+ createdAt: string;
109
+ }
110
+ interface AnchorResult {
111
+ bundleId: string;
112
+ transactionHash: string;
113
+ blockNumber: number;
114
+ network: string;
115
+ explorerUrl: string;
116
+ status: 'pending' | 'confirmed' | 'failed';
117
+ timestamp: string;
118
+ }
119
+ interface VerifyResult {
120
+ bundleId: string;
121
+ verified: boolean;
122
+ checks: {
123
+ integrityValid: boolean;
124
+ timestampValid: boolean;
125
+ ledgerAnchored: boolean;
126
+ hashMatches: boolean;
127
+ };
128
+ ledgerInfo?: {
129
+ transactionHash: string;
130
+ blockNumber: number;
131
+ network: string;
132
+ confirmedAt: string;
133
+ };
134
+ timestamp: string;
135
+ }
136
+ interface CertifyOptions {
137
+ provider?: Provider;
138
+ modelId?: string;
139
+ temperature?: number;
140
+ maxTokens?: number;
141
+ compressionLevel?: CompressionLevel;
142
+ network?: Network;
143
+ skipAnchor?: boolean;
144
+ }
145
+ interface Certificate {
146
+ bundleId: string;
147
+ bundleHash: string;
148
+ verified: boolean;
149
+ explorerUrl?: string;
150
+ transactionHash?: string;
151
+ steps: {
152
+ compress: CompressResult;
153
+ execute: ExecuteResult;
154
+ analyze: AnalyzeResult;
155
+ sign: SignResult;
156
+ bundle: BundleResult;
157
+ anchor?: AnchorResult;
158
+ verify: VerifyResult;
159
+ };
160
+ }
161
+
162
+ declare class ProofAI {
163
+ private apiKey;
164
+ private baseUrl;
165
+ constructor(config: ProofAIConfig);
166
+ private call;
167
+ compress(prompt: string, options?: CompressOptions): Promise<CompressResult>;
168
+ execute(promptRef: string, options: ExecuteOptions): Promise<ExecuteResult>;
169
+ analyze(executionId: string, analysisText: string): Promise<AnalyzeResult>;
170
+ sign(execution: ExecuteResult): Promise<SignResult>;
171
+ bundle(promptId: string, executionId: string, analysisId: string, signatureId: string, cognitiveHash: string): Promise<BundleResult>;
172
+ anchor(bundleId: string, network?: 'polygon' | 'ethereum'): Promise<AnchorResult>;
173
+ verify(bundleId: string): Promise<VerifyResult>;
174
+ certify(prompt: string, options?: CertifyOptions): Promise<Certificate>;
175
+ }
176
+
177
+ export { type AnalyzeResult, type AnchorResult, type BundleResult, type Certificate, type CertifyOptions, type CompressOptions, type CompressResult, type CompressionLevel, type ExecuteOptions, type ExecuteResult, type Network, ProofAI, type ProofAIConfig, type Provider, type SignResult, type VerifyResult, ProofAI as default };
package/dist/index.js ADDED
@@ -0,0 +1,147 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ ProofAI: () => ProofAI,
24
+ default: () => index_default
25
+ });
26
+ module.exports = __toCommonJS(index_exports);
27
+ var DEFAULT_BASE_URL = "https://apzgbajvwzykygrxxrwm.supabase.co/functions/v1";
28
+ var ProofAI = class {
29
+ constructor(config) {
30
+ if (!config.apiKey) throw new Error("ProofAI: apiKey is required");
31
+ this.apiKey = config.apiKey;
32
+ this.baseUrl = config.baseUrl?.replace(/\/$/, "") || DEFAULT_BASE_URL;
33
+ }
34
+ async call(path, body) {
35
+ const res = await fetch(`${this.baseUrl}/${path}`, {
36
+ method: "POST",
37
+ headers: {
38
+ "Content-Type": "application/json",
39
+ "Authorization": `Bearer ${this.apiKey}`
40
+ },
41
+ body: JSON.stringify(body)
42
+ });
43
+ if (!res.ok) {
44
+ const text = await res.text();
45
+ throw new Error(`ProofAI API error ${res.status}: ${text}`);
46
+ }
47
+ return res.json();
48
+ }
49
+ // --- Individual steps ---
50
+ async compress(prompt, options = {}) {
51
+ return this.call("compress", { prompt, options });
52
+ }
53
+ async execute(promptRef, options) {
54
+ const modelDefaults = {
55
+ anthropic: "claude-sonnet-4-20250514",
56
+ openai: "gpt-4-turbo",
57
+ gemini: "gemini-2.0-flash",
58
+ google: "gemini-2.0-flash"
59
+ };
60
+ return this.call("execute", {
61
+ promptRef,
62
+ options: {
63
+ provider: options.provider,
64
+ modelId: options.modelId || modelDefaults[options.provider] || "gpt-4-turbo",
65
+ temperature: options.temperature ?? 0.7,
66
+ maxTokens: options.maxTokens ?? 1024
67
+ }
68
+ });
69
+ }
70
+ async analyze(executionId, analysisText) {
71
+ return this.call("analyze", { executionId, analysisText });
72
+ }
73
+ async sign(execution) {
74
+ const now = (/* @__PURE__ */ new Date()).toISOString();
75
+ return this.call("sign", {
76
+ executionId: execution.id,
77
+ rawOutput: execution.output,
78
+ modelProvider: execution.metadata.provider,
79
+ modelId: execution.metadata.model,
80
+ modelVersion: "latest",
81
+ modelParameters: { temperature: 0.7 },
82
+ executionMetrics: { latency_ms: execution.metadata.latency, tokens: execution.metadata.tokens.total },
83
+ requesterInfo: { source: "proofai-sdk" },
84
+ timestamps: { request_received: now, execution_completed: now }
85
+ });
86
+ }
87
+ async bundle(promptId, executionId, analysisId, signatureId, cognitiveHash) {
88
+ return this.call("bundle", { promptId, executionId, analysisId, signatureId, cognitiveHash });
89
+ }
90
+ async anchor(bundleId, network = "polygon") {
91
+ return this.call("anchor", { bundleId, network });
92
+ }
93
+ async verify(bundleId) {
94
+ return this.call("verify", { bundleId });
95
+ }
96
+ // --- Full pipeline in one call ---
97
+ async certify(prompt, options = {}) {
98
+ const provider = options.provider || "anthropic";
99
+ const compressed = await this.compress(prompt, {
100
+ compressionLevel: options.compressionLevel || "medium"
101
+ });
102
+ const execution = await this.execute(compressed.id, {
103
+ provider,
104
+ modelId: options.modelId,
105
+ temperature: options.temperature,
106
+ maxTokens: options.maxTokens
107
+ });
108
+ const analysis = await this.analyze(execution.id, execution.output);
109
+ const signature = await this.sign(execution);
110
+ const evidenceBundle = await this.bundle(
111
+ compressed.id,
112
+ execution.id,
113
+ analysis.id,
114
+ signature.signatureId,
115
+ analysis.cognitiveHash
116
+ );
117
+ let anchorResult;
118
+ if (!options.skipAnchor) {
119
+ try {
120
+ anchorResult = await this.anchor(evidenceBundle.id, options.network || "polygon");
121
+ } catch {
122
+ }
123
+ }
124
+ const verification = await this.verify(evidenceBundle.id);
125
+ return {
126
+ bundleId: evidenceBundle.id,
127
+ bundleHash: evidenceBundle.bundleHash,
128
+ verified: verification.verified,
129
+ explorerUrl: anchorResult?.explorerUrl,
130
+ transactionHash: anchorResult?.transactionHash,
131
+ steps: {
132
+ compress: compressed,
133
+ execute: execution,
134
+ analyze: analysis,
135
+ sign: signature,
136
+ bundle: evidenceBundle,
137
+ anchor: anchorResult,
138
+ verify: verification
139
+ }
140
+ };
141
+ }
142
+ };
143
+ var index_default = ProofAI;
144
+ // Annotate the CommonJS export names for ESM import in node:
145
+ 0 && (module.exports = {
146
+ ProofAI
147
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,122 @@
1
+ // src/index.ts
2
+ var DEFAULT_BASE_URL = "https://apzgbajvwzykygrxxrwm.supabase.co/functions/v1";
3
+ var ProofAI = class {
4
+ constructor(config) {
5
+ if (!config.apiKey) throw new Error("ProofAI: apiKey is required");
6
+ this.apiKey = config.apiKey;
7
+ this.baseUrl = config.baseUrl?.replace(/\/$/, "") || DEFAULT_BASE_URL;
8
+ }
9
+ async call(path, body) {
10
+ const res = await fetch(`${this.baseUrl}/${path}`, {
11
+ method: "POST",
12
+ headers: {
13
+ "Content-Type": "application/json",
14
+ "Authorization": `Bearer ${this.apiKey}`
15
+ },
16
+ body: JSON.stringify(body)
17
+ });
18
+ if (!res.ok) {
19
+ const text = await res.text();
20
+ throw new Error(`ProofAI API error ${res.status}: ${text}`);
21
+ }
22
+ return res.json();
23
+ }
24
+ // --- Individual steps ---
25
+ async compress(prompt, options = {}) {
26
+ return this.call("compress", { prompt, options });
27
+ }
28
+ async execute(promptRef, options) {
29
+ const modelDefaults = {
30
+ anthropic: "claude-sonnet-4-20250514",
31
+ openai: "gpt-4-turbo",
32
+ gemini: "gemini-2.0-flash",
33
+ google: "gemini-2.0-flash"
34
+ };
35
+ return this.call("execute", {
36
+ promptRef,
37
+ options: {
38
+ provider: options.provider,
39
+ modelId: options.modelId || modelDefaults[options.provider] || "gpt-4-turbo",
40
+ temperature: options.temperature ?? 0.7,
41
+ maxTokens: options.maxTokens ?? 1024
42
+ }
43
+ });
44
+ }
45
+ async analyze(executionId, analysisText) {
46
+ return this.call("analyze", { executionId, analysisText });
47
+ }
48
+ async sign(execution) {
49
+ const now = (/* @__PURE__ */ new Date()).toISOString();
50
+ return this.call("sign", {
51
+ executionId: execution.id,
52
+ rawOutput: execution.output,
53
+ modelProvider: execution.metadata.provider,
54
+ modelId: execution.metadata.model,
55
+ modelVersion: "latest",
56
+ modelParameters: { temperature: 0.7 },
57
+ executionMetrics: { latency_ms: execution.metadata.latency, tokens: execution.metadata.tokens.total },
58
+ requesterInfo: { source: "proofai-sdk" },
59
+ timestamps: { request_received: now, execution_completed: now }
60
+ });
61
+ }
62
+ async bundle(promptId, executionId, analysisId, signatureId, cognitiveHash) {
63
+ return this.call("bundle", { promptId, executionId, analysisId, signatureId, cognitiveHash });
64
+ }
65
+ async anchor(bundleId, network = "polygon") {
66
+ return this.call("anchor", { bundleId, network });
67
+ }
68
+ async verify(bundleId) {
69
+ return this.call("verify", { bundleId });
70
+ }
71
+ // --- Full pipeline in one call ---
72
+ async certify(prompt, options = {}) {
73
+ const provider = options.provider || "anthropic";
74
+ const compressed = await this.compress(prompt, {
75
+ compressionLevel: options.compressionLevel || "medium"
76
+ });
77
+ const execution = await this.execute(compressed.id, {
78
+ provider,
79
+ modelId: options.modelId,
80
+ temperature: options.temperature,
81
+ maxTokens: options.maxTokens
82
+ });
83
+ const analysis = await this.analyze(execution.id, execution.output);
84
+ const signature = await this.sign(execution);
85
+ const evidenceBundle = await this.bundle(
86
+ compressed.id,
87
+ execution.id,
88
+ analysis.id,
89
+ signature.signatureId,
90
+ analysis.cognitiveHash
91
+ );
92
+ let anchorResult;
93
+ if (!options.skipAnchor) {
94
+ try {
95
+ anchorResult = await this.anchor(evidenceBundle.id, options.network || "polygon");
96
+ } catch {
97
+ }
98
+ }
99
+ const verification = await this.verify(evidenceBundle.id);
100
+ return {
101
+ bundleId: evidenceBundle.id,
102
+ bundleHash: evidenceBundle.bundleHash,
103
+ verified: verification.verified,
104
+ explorerUrl: anchorResult?.explorerUrl,
105
+ transactionHash: anchorResult?.transactionHash,
106
+ steps: {
107
+ compress: compressed,
108
+ execute: execution,
109
+ analyze: analysis,
110
+ sign: signature,
111
+ bundle: evidenceBundle,
112
+ anchor: anchorResult,
113
+ verify: verification
114
+ }
115
+ };
116
+ }
117
+ };
118
+ var index_default = ProofAI;
119
+ export {
120
+ ProofAI,
121
+ index_default as default
122
+ };
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@proofai/sdk",
3
+ "version": "1.0.0",
4
+ "description": "ProofAI SDK — Cryptographic proof that AI thought before it answered",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "files": ["dist"],
9
+ "scripts": {
10
+ "build": "tsup src/index.ts --format cjs,esm --dts",
11
+ "prepublishOnly": "npm run build"
12
+ },
13
+ "keywords": ["ai", "proof", "blockchain", "ed25519", "evidence", "compliance", "audit"],
14
+ "author": "HIRAM",
15
+ "license": "MIT",
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "https://github.com/scorentab-afk/proofai"
19
+ },
20
+ "devDependencies": {
21
+ "tsup": "^8.0.0",
22
+ "typescript": "^5.8.0"
23
+ }
24
+ }