@rubric-protocol/sdk 1.1.1 → 1.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.
- package/README.md +178 -90
- package/dist/background-queue.d.ts +57 -0
- package/dist/background-queue.d.ts.map +1 -0
- package/dist/background-queue.js +164 -0
- package/dist/background-queue.js.map +1 -0
- package/dist/index.d.ts +14 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +25 -20
- package/dist/index.js.map +1 -1
- package/dist/ml-dsa-local.d.ts +35 -0
- package/dist/ml-dsa-local.d.ts.map +1 -0
- package/dist/ml-dsa-local.js +151 -0
- package/dist/ml-dsa-local.js.map +1 -0
- package/dist/plugins/langchain.d.ts +30 -0
- package/dist/plugins/langchain.d.ts.map +1 -0
- package/dist/plugins/langchain.js +85 -0
- package/dist/plugins/langchain.js.map +1 -0
- package/dist/plugins/openai-plugin.d.ts +23 -0
- package/dist/plugins/openai-plugin.d.ts.map +1 -0
- package/dist/plugins/openai-plugin.js +72 -0
- package/dist/plugins/openai-plugin.js.map +1 -0
- package/dist/proof-types.d.ts +48 -0
- package/dist/proof-types.d.ts.map +1 -0
- package/dist/proof-types.js +105 -0
- package/dist/proof-types.js.map +1 -0
- package/dist/proof-upgrade-manager.d.ts +24 -0
- package/dist/proof-upgrade-manager.d.ts.map +1 -0
- package/dist/proof-upgrade-manager.js +103 -0
- package/dist/proof-upgrade-manager.js.map +1 -0
- package/dist/rubric-client.d.ts +104 -0
- package/dist/rubric-client.d.ts.map +1 -0
- package/dist/rubric-client.js +243 -0
- package/dist/rubric-client.js.map +1 -0
- package/dist/signing.d.ts +35 -0
- package/dist/signing.d.ts.map +1 -0
- package/dist/signing.js +151 -0
- package/dist/signing.js.map +1 -0
- package/package.json +43 -12
- package/dist/cli.d.ts +0 -30
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js +0 -165
- package/dist/cli.js.map +0 -1
- package/dist/client.d.ts +0 -379
- package/dist/client.d.ts.map +0 -1
- package/dist/client.js +0 -447
- package/dist/client.js.map +0 -1
- package/dist/types.d.ts +0 -296
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -6
- package/dist/types.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
# @rubric-protocol/sdk
|
|
2
2
|
|
|
3
|
-
Post-quantum AI attestation
|
|
3
|
+
Post-quantum AI attestation for Node.js. Every AI decision your system makes — signed locally in microseconds, anchored to Hedera's public ledger in the background.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Built for [EU AI Act Article 12](https://rubric-protocol.com) compliance and beyond.
|
|
6
|
+
|
|
7
|
+
---
|
|
6
8
|
|
|
7
9
|
|
|
8
10
|
## ⚠️ Critical: /v1/attest vs /v1/tiered-attest
|
|
@@ -16,127 +18,213 @@ Rubric Protocol is the independent witness layer for the AI economy - providing
|
|
|
16
18
|
`/v1/attest` is a direct HCS write. Unguarded use drained 1,000 HBAR in 12 hours.
|
|
17
19
|
Hard rate limit: 60 req/min. If you are unsure which to use: use `/v1/tiered-attest`.
|
|
18
20
|
|
|
19
|
-
##
|
|
21
|
+
## How it works
|
|
22
|
+
|
|
23
|
+
The SDK signs AI decisions locally using ML-DSA-65 (NIST FIPS 204, post-quantum) before any network call is made. Attestations are queued and flushed to Rubric's global federation in the background. Your AI pipeline sees zero added latency.
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
AI decision ‒ local sign (<1ms) → proof returned immediately
|
|
27
|
+
↓ background
|
|
28
|
+
Rubric anchor (5-10s) → HCS confirmed (~30s)
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Each proof upgrades automatically as anchoring completes. You can fire-and-forget, or await full HCS confirmation for high-stakes decisions.
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Install
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npm install @rubric-protocol/sdk
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Peer dependencies (install only what you use):
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
npm install openai # for OpenAI plugin
|
|
45
|
+
npm install @langchain/core # for LangChain plugin
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Quickstart
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
import { createRubricClient } from '@rubric-protocol/sdk';
|
|
54
|
+
|
|
55
|
+
const rubric = createRubricClient({
|
|
56
|
+
apiKey: process.env.RUBRIC_API_KEY!,
|
|
57
|
+
localSigning: true, // sign locally before network
|
|
58
|
+
backgroundQueue: true, // non-blocking flush
|
|
59
|
+
node: 'auto', // route to nearest healthy node
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const proof = await rubric.attest({
|
|
63
|
+
agentId: 'my-agent-v1',
|
|
64
|
+
output: 'Loan application approved. Score: 742, DTI: 28%.',
|
|
65
|
+
leafType: 'AGENT_OUTPUT',
|
|
66
|
+
metadata: { model: 'gpt-4o', pipeline: 'credit-decisioning' },
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
console.log(proof.attestationId); // immediate
|
|
70
|
+
console.log(proof.stage); // 'local'
|
|
71
|
+
|
|
72
|
+
// Optional: wait for full HCS confirmation
|
|
73
|
+
proof.onUpgrade('confirmed', (confirmed) => {
|
|
74
|
+
console.log(confirmed.hashScanUrl); // publicly verifiable on HashScan
|
|
75
|
+
});
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## LangChain
|
|
81
|
+
|
|
82
|
+
Add one handler and every LLM call, agent action, chain, and tool invocation is automatically attested.
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
import { ChatOpenAI } from '@langchain/openai';
|
|
86
|
+
import { AgentExecutor } from 'langchain/agents';
|
|
87
|
+
import { RubricLangChainHandler } from '@rubric-protocol/sdk';
|
|
88
|
+
|
|
89
|
+
const rubric = new RubricLangChainHandler({
|
|
90
|
+
apiKey: process.env.RUBRIC_API_KEY!,
|
|
91
|
+
localSigning: true,
|
|
92
|
+
backgroundQueue: true,
|
|
93
|
+
events: ['llm', 'agent', 'tool'], // choose what to attest
|
|
94
|
+
pipelineId: 'my-pipeline',
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const executor = await AgentExecutor.fromAgentAndTools({
|
|
98
|
+
agent,
|
|
99
|
+
tools,
|
|
100
|
+
callbacks: [rubric], // that's it
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
await executor.invoke({ input: 'Analyze this transaction for fraud.' });
|
|
104
|
+
await rubric.shutdown(); // flush remaining queue on exit
|
|
105
|
+
```
|
|
20
106
|
|
|
21
|
-
|
|
107
|
+
---
|
|
22
108
|
|
|
23
|
-
##
|
|
109
|
+
## OpenAI
|
|
24
110
|
|
|
25
|
-
|
|
26
|
-
const client = new RubricClient({
|
|
27
|
-
baseUrl: "https://rubric-protocol.com/verify",
|
|
28
|
-
apiKey: "your-api-key",
|
|
29
|
-
});
|
|
111
|
+
Drop-in wrapper — your existing code is unchanged.
|
|
30
112
|
|
|
31
|
-
|
|
113
|
+
```typescript
|
|
114
|
+
import OpenAI from 'openai';
|
|
115
|
+
import { withRubric } from '@rubric-protocol/sdk';
|
|
32
116
|
|
|
33
|
-
|
|
117
|
+
const openai = withRubric(new OpenAI(), {
|
|
118
|
+
apiKey: process.env.RUBRIC_API_KEY!,
|
|
119
|
+
agentId: 'my-openai-agent',
|
|
120
|
+
localSigning: true,
|
|
121
|
+
backgroundQueue: true,
|
|
122
|
+
});
|
|
34
123
|
|
|
35
|
-
|
|
124
|
+
// Use exactly as before — attestation happens automatically
|
|
125
|
+
const completion = await openai.chat.completions.create({
|
|
126
|
+
model: 'gpt-4o',
|
|
127
|
+
messages: [{ role: 'user', content: 'Should we approve this claim?' }],
|
|
128
|
+
});
|
|
129
|
+
```
|
|
36
130
|
|
|
37
|
-
|
|
38
|
-
2. A Merkle inclusion - aggregated into a cryptographic tree and anchored to Hedera Consensus Service
|
|
39
|
-
3. A ZK inclusion proof - independently verifiable proof your record was included in the anchored tree
|
|
131
|
+
---
|
|
40
132
|
|
|
41
|
-
|
|
133
|
+
## High-stakes decisions
|
|
42
134
|
|
|
43
|
-
|
|
135
|
+
For decisions requiring immediate confirmation (medical triage, credit denial, hiring rejection), await full HCS anchoring:
|
|
44
136
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
137
|
+
```typescript
|
|
138
|
+
const confirmed = await rubric.attestAndConfirm({
|
|
139
|
+
agentId: 'triage-agent',
|
|
140
|
+
output: 'Patient flagged for immediate review.',
|
|
141
|
+
leafType: 'AGENT_OUTPUT',
|
|
142
|
+
risk: 'high',
|
|
143
|
+
}, 90_000); // timeout ms
|
|
52
144
|
|
|
53
|
-
|
|
145
|
+
console.log(confirmed.hcsSequenceNumber);
|
|
146
|
+
console.log(confirmed.hashScanUrl); // immutable public record
|
|
147
|
+
```
|
|
54
148
|
|
|
55
|
-
|
|
149
|
+
---
|
|
56
150
|
|
|
57
|
-
|
|
58
|
-
timeoutMs: 120_000, // default 120s
|
|
59
|
-
intervalMs: 10_000, // default 10s
|
|
60
|
-
});
|
|
61
|
-
console.log(proof.status); // ready
|
|
62
|
-
console.log(proof.proof.zkRoot); // Poseidon2 Merkle root
|
|
63
|
-
console.log(proof.proof.zkPath); // 20-level inclusion path
|
|
64
|
-
console.log(proof.proof.zkLeaf); // your record leaf hash
|
|
65
|
-
console.log(proof.hcsSeqNum); // HCS sequence number
|
|
66
|
-
console.log(proof.verifyEndpoint); // endpoint to verify this proof
|
|
151
|
+
## Proof lifecycle
|
|
67
152
|
|
|
68
|
-
|
|
153
|
+
Every attestation returns a `LiveProof` that upgrades automatically:
|
|
69
154
|
|
|
70
|
-
|
|
155
|
+
| Stage | When | What you have |
|
|
156
|
+
|---|---|---|
|
|
157
|
+
| `local` | <1ms | ML-DSA-65 signature + timestamp |
|
|
158
|
+
| `anchored` | 5–10s | Merkle root committed to Rubric |
|
|
159
|
+
| `confirmed` | ~30s | HCS sequence number, HashScan URL |
|
|
71
160
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
proof.zkLeaf BN254 field element - your record leaf hash
|
|
78
|
-
proof.zkRoot Poseidon2 Merkle root - matches HCS anchor
|
|
79
|
-
proof.zkPath 20-element sibling path
|
|
80
|
-
proof.zkIndices left/right indices per level
|
|
81
|
-
proof.leafIndex your position in the Merkle tree
|
|
82
|
-
circuitVersion noir-beta19-poseidon2-depth20
|
|
161
|
+
```typescript
|
|
162
|
+
proof.onUpgrade('anchored', (p) => console.log(p.merkleRoot));
|
|
163
|
+
proof.onUpgrade('confirmed', (p) => console.log(p.hashScanUrl));
|
|
164
|
+
proof.onUpgrade('any', (p) => console.log(p.stage)); // fires on each upgrade
|
|
165
|
+
```
|
|
83
166
|
|
|
84
|
-
|
|
167
|
+
---
|
|
85
168
|
|
|
86
|
-
|
|
87
|
-
const client = new RubricClient({
|
|
88
|
-
baseUrl: "https://rubric-protocol.com/verify",
|
|
89
|
-
apiKey: process.env.RUBRIC_API_KEY,
|
|
90
|
-
});
|
|
91
|
-
const attest = await client.attestations.tieredAttest({
|
|
92
|
-
data: { model: "claude-3-5-sonnet", action: "content_moderation", result: "approved" },
|
|
93
|
-
sourceId: "my-ai-system",
|
|
94
|
-
});
|
|
95
|
-
const proof = await client.attestations.getZkProof(attest.attestationId);
|
|
96
|
-
console.log("zkRoot: ", proof.proof.zkRoot);
|
|
97
|
-
console.log("leafIndex:", proof.proof.leafIndex);
|
|
98
|
-
console.log("hcsSeqNum:", proof.hcsSeqNum ?? "pending");
|
|
169
|
+
## Configuration
|
|
99
170
|
|
|
100
|
-
|
|
171
|
+
```typescript
|
|
172
|
+
createRubricClient({
|
|
173
|
+
apiKey: string, // required — get one at rubric-protocol.com
|
|
174
|
+
node?: 'us'|'sg'|'jp'|'ca'|'eu'|'auto', // default: 'us'
|
|
175
|
+
localSigning?: boolean, // default: false
|
|
176
|
+
keystorePath?: string, // default: ~/.rubric/sdk-keypair.json
|
|
177
|
+
keystorePassphrase?: string, // AES-256-GCM encrypts the keystore
|
|
178
|
+
backgroundQueue?: boolean, // default: false
|
|
179
|
+
enterprise?: boolean, // uses /v1/tiered-attest (Merkle batching)
|
|
180
|
+
proofUpgrade?: boolean, // auto-poll for stage upgrades
|
|
181
|
+
timeout?: number, // HTTP timeout ms, default: 15000
|
|
182
|
+
})
|
|
183
|
+
```
|
|
101
184
|
|
|
102
|
-
|
|
185
|
+
---
|
|
103
186
|
|
|
104
|
-
|
|
187
|
+
## Nodes
|
|
105
188
|
|
|
106
|
-
|
|
189
|
+
The SDK routes to Rubric's global federation automatically when `node: 'auto'`.
|
|
107
190
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
191
|
+
| Region | Endpoint |
|
|
192
|
+
|---|---|
|
|
193
|
+
| US East | `https://rubric-protocol.com/verify` |
|
|
194
|
+
| Singapore | `https://sg.rubric-protocol.com/verify` |
|
|
195
|
+
| Japan | `https://jp.rubric-protocol.com/verify` |
|
|
196
|
+
| Canada | `https://ca.rubric-protocol.com/verify` |
|
|
197
|
+
| EU Central | `https://eu.rubric-protocol.com/verify` |
|
|
111
198
|
|
|
112
|
-
|
|
199
|
+
---
|
|
113
200
|
|
|
114
|
-
|
|
201
|
+
## Security
|
|
115
202
|
|
|
116
|
-
|
|
203
|
+
- **ML-DSA-65** (NIST FIPS 204) — post-quantum signature scheme, same algorithm used server-side
|
|
204
|
+
- Keypairs stored at `~/.rubric/sdk-keypair.json` with optional AES-256-GCM encryption via passphrase
|
|
205
|
+
- Canonical JSON serialization ensures deterministic, tamper-evident signing
|
|
206
|
+
- All attestations anchored to [Hedera Consensus Service](https://hedera.com) — public, immutable, independently verifiable
|
|
117
207
|
|
|
118
|
-
|
|
119
|
-
await mySecretsManager.store(' + chr(39) + 'rubric:key:' + chr(39) + ' + result.attestationId, result.payloadKey);
|
|
208
|
+
---
|
|
120
209
|
|
|
121
|
-
##
|
|
210
|
+
## Requirements
|
|
122
211
|
|
|
123
|
-
|
|
212
|
+
- Node.js >= 18.0.0
|
|
213
|
+
- TypeScript >= 5.0 (if using TypeScript)
|
|
124
214
|
|
|
125
|
-
|
|
126
|
-
- Structural immutability: HCS has no DELETE or UPDATE operation by design
|
|
127
|
-
- Third-party verifiability: records verifiable against Hedera public mirror nodes without Rubric
|
|
128
|
-
- Post-quantum integrity: ML-DSA-65 signatures valid against quantum adversaries
|
|
129
|
-
- ZK inclusion proofs: customers hold independent cryptographic evidence of inclusion
|
|
215
|
+
---
|
|
130
216
|
|
|
131
|
-
##
|
|
217
|
+
## Links
|
|
132
218
|
|
|
133
|
-
|
|
219
|
+
- [Documentation](https://rubric-protocol.com)
|
|
220
|
+
- [API Reference](https://rubric-protocol.com/docs)
|
|
221
|
+
- [HashScan](https://hashscan.io/testnet/topic/0.0.8207826) — live attestation stream
|
|
222
|
+
- [EU AI Act Article 12](https://eur-lex.europa.eu/legal-content/EN/TXT/?uri=CELEX:32024R1689)
|
|
134
223
|
|
|
135
|
-
|
|
224
|
+
---
|
|
136
225
|
|
|
137
|
-
##
|
|
226
|
+
## License
|
|
138
227
|
|
|
139
|
-
|
|
140
|
-
Email: scott@rubric-protocol.com
|
|
228
|
+
MIT — Echelon Intelligence Systems LLC
|
|
141
229
|
|
|
142
|
-
|
|
230
|
+
*Patent Pending*
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rubric Protocol — Background Attestation Queue
|
|
3
|
+
* Buffers attestation calls, submits in batches, retries on failure.
|
|
4
|
+
* Survives process restart via optional JSON persistence.
|
|
5
|
+
*/
|
|
6
|
+
export interface QueueItem {
|
|
7
|
+
id: string;
|
|
8
|
+
endpoint: string;
|
|
9
|
+
payload: Record<string, unknown>;
|
|
10
|
+
headers: Record<string, string>;
|
|
11
|
+
attempts: number;
|
|
12
|
+
maxAttempts: number;
|
|
13
|
+
nextRetryAt: number;
|
|
14
|
+
enqueuedAt: number;
|
|
15
|
+
failedPermanently?: boolean;
|
|
16
|
+
lastError?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface QueueConfig {
|
|
19
|
+
flushInterval?: number;
|
|
20
|
+
batchSize?: number;
|
|
21
|
+
maxAttempts?: number;
|
|
22
|
+
backoffBase?: number;
|
|
23
|
+
persistPath?: string;
|
|
24
|
+
onDeadLetter?: (item: QueueItem) => void;
|
|
25
|
+
onSuccess?: (item: QueueItem, response: unknown) => void;
|
|
26
|
+
onError?: (item: QueueItem, error: Error) => void;
|
|
27
|
+
}
|
|
28
|
+
export type QueueStats = {
|
|
29
|
+
queued: number;
|
|
30
|
+
inflight: number;
|
|
31
|
+
deadLetters: number;
|
|
32
|
+
totalSubmitted: number;
|
|
33
|
+
totalFailed: number;
|
|
34
|
+
};
|
|
35
|
+
export declare class BackgroundQueue {
|
|
36
|
+
private queue;
|
|
37
|
+
private deadLetters;
|
|
38
|
+
private inflight;
|
|
39
|
+
private timer;
|
|
40
|
+
private totalSubmitted;
|
|
41
|
+
private totalFailed;
|
|
42
|
+
private readonly config;
|
|
43
|
+
constructor(config?: QueueConfig);
|
|
44
|
+
enqueue(endpoint: string, payload: Record<string, unknown>, headers: Record<string, string>, options?: {
|
|
45
|
+
maxAttempts?: number;
|
|
46
|
+
}): string;
|
|
47
|
+
start(): void;
|
|
48
|
+
stop(): Promise<void>;
|
|
49
|
+
stats(): QueueStats;
|
|
50
|
+
flush(): Promise<void>;
|
|
51
|
+
private _flush;
|
|
52
|
+
private _submit;
|
|
53
|
+
private _persist;
|
|
54
|
+
private _loadFromDisk;
|
|
55
|
+
}
|
|
56
|
+
export declare function sleep(ms: number): Promise<void>;
|
|
57
|
+
//# sourceMappingURL=background-queue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"background-queue.d.ts","sourceRoot":"","sources":["../background-queue.ts"],"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;IAC5D,OAAO,CAAC,cAAc,CAAK;IAC3B,OAAO,CAAC,WAAW,CAAK;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAM;gBAEjB,MAAM,GAAE,WAAgB;IAapC,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,GAAE;QAAE,WAAW,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,MAAM;IAO5I,KAAK,IAAI,IAAI;IAOP,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAO3B,KAAK,IAAI,UAAU;IAIb,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;YAEd,MAAM;YAMN,OAAO;IA0BrB,OAAO,CAAC,QAAQ;IAOhB,OAAO,CAAC,aAAa;CAUtB;AAED,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE/C"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Rubric Protocol — Background Attestation Queue
|
|
4
|
+
* Buffers attestation calls, submits in batches, retries on failure.
|
|
5
|
+
* Survives process restart via optional JSON persistence.
|
|
6
|
+
*/
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
+
}) : function(o, v) {
|
|
21
|
+
o["default"] = v;
|
|
22
|
+
});
|
|
23
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
24
|
+
var ownKeys = function(o) {
|
|
25
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26
|
+
var ar = [];
|
|
27
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
28
|
+
return ar;
|
|
29
|
+
};
|
|
30
|
+
return ownKeys(o);
|
|
31
|
+
};
|
|
32
|
+
return function (mod) {
|
|
33
|
+
if (mod && mod.__esModule) return mod;
|
|
34
|
+
var result = {};
|
|
35
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
36
|
+
__setModuleDefault(result, mod);
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
})();
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
exports.BackgroundQueue = void 0;
|
|
42
|
+
exports.sleep = sleep;
|
|
43
|
+
const fs = __importStar(require("fs"));
|
|
44
|
+
const crypto = __importStar(require("crypto"));
|
|
45
|
+
class BackgroundQueue {
|
|
46
|
+
constructor(config = {}) {
|
|
47
|
+
this.queue = new Map();
|
|
48
|
+
this.deadLetters = [];
|
|
49
|
+
this.inflight = new Set();
|
|
50
|
+
this.timer = null;
|
|
51
|
+
this.totalSubmitted = 0;
|
|
52
|
+
this.totalFailed = 0;
|
|
53
|
+
this.config = {
|
|
54
|
+
flushInterval: config.flushInterval ?? 2000,
|
|
55
|
+
batchSize: config.batchSize ?? 50,
|
|
56
|
+
maxAttempts: config.maxAttempts ?? 5,
|
|
57
|
+
backoffBase: config.backoffBase ?? 1000,
|
|
58
|
+
persistPath: config.persistPath,
|
|
59
|
+
onDeadLetter: config.onDeadLetter,
|
|
60
|
+
onSuccess: config.onSuccess,
|
|
61
|
+
onError: config.onError,
|
|
62
|
+
};
|
|
63
|
+
if (this.config.persistPath)
|
|
64
|
+
this._loadFromDisk();
|
|
65
|
+
}
|
|
66
|
+
enqueue(endpoint, payload, headers, options = {}) {
|
|
67
|
+
const id = crypto.randomUUID();
|
|
68
|
+
this.queue.set(id, { id, endpoint, payload, headers, attempts: 0, maxAttempts: options.maxAttempts ?? this.config.maxAttempts, nextRetryAt: Date.now(), enqueuedAt: Date.now() });
|
|
69
|
+
this._persist();
|
|
70
|
+
return id;
|
|
71
|
+
}
|
|
72
|
+
start() {
|
|
73
|
+
if (this.timer)
|
|
74
|
+
return;
|
|
75
|
+
this.timer = setInterval(() => this._flush(), this.config.flushInterval);
|
|
76
|
+
if (typeof this.timer === 'object' && 'unref' in this.timer)
|
|
77
|
+
this.timer.unref();
|
|
78
|
+
this._flush();
|
|
79
|
+
}
|
|
80
|
+
async stop() {
|
|
81
|
+
if (this.timer) {
|
|
82
|
+
clearInterval(this.timer);
|
|
83
|
+
this.timer = null;
|
|
84
|
+
}
|
|
85
|
+
const deadline = Date.now() + 10000;
|
|
86
|
+
while (this.inflight.size > 0 && Date.now() < deadline)
|
|
87
|
+
await new Promise(r0 => setTimeout(r0, 100));
|
|
88
|
+
this._persist();
|
|
89
|
+
}
|
|
90
|
+
stats() {
|
|
91
|
+
return { queued: this.queue.size, inflight: this.inflight.size, deadLetters: this.deadLetters.length, totalSubmitted: this.totalSubmitted, totalFailed: this.totalFailed };
|
|
92
|
+
}
|
|
93
|
+
async flush() { await this._flush(); }
|
|
94
|
+
async _flush() {
|
|
95
|
+
const now = Date.now();
|
|
96
|
+
const eligible = [...this.queue.values()].filter(i => !this.inflight.has(i.id) && i.nextRetryAt <= now).slice(0, this.config.batchSize);
|
|
97
|
+
if (eligible.length === 0)
|
|
98
|
+
return;
|
|
99
|
+
await Promise.allSettled(eligible.map(i => this._submit(i)));
|
|
100
|
+
}
|
|
101
|
+
async _submit(item) {
|
|
102
|
+
this.inflight.add(item.id);
|
|
103
|
+
item.attempts++;
|
|
104
|
+
try {
|
|
105
|
+
const res = await fetch(item.endpoint, { method: 'POST', headers: { 'Content-Type': 'application/json', ...item.headers }, body: JSON.stringify(item.payload), signal: AbortSignal.timeout(15000) });
|
|
106
|
+
if (!res.ok) {
|
|
107
|
+
const b = await res.text().catch(() => '');
|
|
108
|
+
throw new Error(`HTTP ${res.status}: ${b.slice(0, 200)}`);
|
|
109
|
+
}
|
|
110
|
+
const response = await res.json().catch(() => null);
|
|
111
|
+
this.queue.delete(item.id);
|
|
112
|
+
this.inflight.delete(item.id);
|
|
113
|
+
this.totalSubmitted++;
|
|
114
|
+
this.config.onSuccess?.(item, response);
|
|
115
|
+
this._persist();
|
|
116
|
+
}
|
|
117
|
+
catch (err) {
|
|
118
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
119
|
+
item.lastError = error.message;
|
|
120
|
+
this.inflight.delete(item.id);
|
|
121
|
+
this.config.onError?.(item, error);
|
|
122
|
+
if (item.attempts >= item.maxAttempts) {
|
|
123
|
+
item.failedPermanently = true;
|
|
124
|
+
this.queue.delete(item.id);
|
|
125
|
+
this.deadLetters.push(item);
|
|
126
|
+
this.totalFailed++;
|
|
127
|
+
this.config.onDeadLetter?.(item);
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
const baseDelay = this.config.backoffBase * Math.pow(2, item.attempts - 1);
|
|
131
|
+
const jitter = baseDelay * 0.1 * (Math.random() * 2 - 1);
|
|
132
|
+
item.nextRetryAt = Date.now() + Math.round(baseDelay + jitter);
|
|
133
|
+
}
|
|
134
|
+
this._persist();
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
_persist() {
|
|
138
|
+
if (!this.config.persistPath)
|
|
139
|
+
return;
|
|
140
|
+
try {
|
|
141
|
+
fs.writeFileSync(this.config.persistPath, JSON.stringify({ version: 1, savedAt: new Date().toISOString(), queue: [...this.queue.values()], deadLetters: this.deadLetters }), { encoding: 'utf8' });
|
|
142
|
+
}
|
|
143
|
+
catch { /* non-fatal */ }
|
|
144
|
+
}
|
|
145
|
+
_loadFromDisk() {
|
|
146
|
+
if (!this.config.persistPath || !fs.existsSync(this.config.persistPath))
|
|
147
|
+
return;
|
|
148
|
+
try {
|
|
149
|
+
const data = JSON.parse(fs.readFileSync(this.config.persistPath, 'utf8'));
|
|
150
|
+
if (data.version !== 1)
|
|
151
|
+
return;
|
|
152
|
+
for (const item of (data.queue ?? []))
|
|
153
|
+
this.queue.set(item.id, item);
|
|
154
|
+
this.deadLetters = data.deadLetters ?? [];
|
|
155
|
+
console.log(`[RubricQueue] Restored ${this.queue.size} items from disk`);
|
|
156
|
+
}
|
|
157
|
+
catch { /* corrupt file - start fresh */ }
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
exports.BackgroundQueue = BackgroundQueue;
|
|
161
|
+
function sleep(ms) {
|
|
162
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
163
|
+
}
|
|
164
|
+
//# sourceMappingURL=background-queue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"background-queue.js","sourceRoot":"","sources":["../background-queue.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyIH,sBAEC;AAzID,uCAAyB;AACzB,+CAAiC;AAkCjC,MAAa,eAAe;IAS1B,YAAY,SAAsB,EAAE;QAR5B,UAAK,GAA2B,IAAI,GAAG,EAAE,CAAC;QAC1C,gBAAW,GAAgB,EAAE,CAAC;QAC9B,aAAQ,GAAgB,IAAI,GAAG,EAAE,CAAC;QAClC,UAAK,GAA0C,IAAI,CAAC;QACpD,mBAAc,GAAG,CAAC,CAAC;QACnB,gBAAW,GAAG,CAAC,CAAC;QAItB,IAAI,CAAC,MAAM,GAAG;YACZ,aAAa,EAAE,MAAM,CAAC,aAAa,IAAI,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AAC,GAAG,CAAC,0BAA0B,IAAI,CAAC,KAAK,CAAC,IAAI,kBAAkB,CAAC,CAAC;QAC3E,CAAC;QAAC,MAAM,CAAC,CAAC,gCAAgC,CAAC,CAAC;IAC9C,CAAC;CACF;AAlGD,0CAkGC;AAED,SAAgB,KAAK,CAAC,EAAU;IAC9B,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AACzD,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export
|
|
1
|
+
export { RubricClient, createRubricClient } from './rubric-client';
|
|
2
|
+
export type { RubricClientConfig, AttestationRequest } from './rubric-client';
|
|
3
|
+
export { LiveProof, STAGE_METADATA } from './proof-types';
|
|
4
|
+
export type { ProofStage, LocalProofData, AnchoredProofData, ConfirmedProofData, AnyProofData, UpgradeCallback } from './proof-types';
|
|
5
|
+
export { ProofUpgradeManager, getUpgradeManager, resetUpgradeManager } from './proof-upgrade-manager';
|
|
6
|
+
export type { UpgradeManagerConfig } from './proof-upgrade-manager';
|
|
7
|
+
export { generateKeyPair, signPayload, verifySignedPayload, loadOrCreateKeyPair, saveKeyPair, loadKeyPair } from './signing';
|
|
8
|
+
export type { LocalKeyPair, SignedPayload } from './signing';
|
|
9
|
+
export { BackgroundQueue } from './background-queue';
|
|
10
|
+
export type { QueueItem, QueueConfig, QueueStats } from './background-queue';
|
|
11
|
+
export { RubricLangChainHandler } from './plugins/langchain';
|
|
12
|
+
export type { RubricLangChainConfig } from './plugins/langchain';
|
|
13
|
+
export { withRubric, RubricOpenAIClient } from './plugins/openai-plugin';
|
|
14
|
+
export type { RubricOpenAIConfig } from './plugins/openai-plugin';
|
|
3
15
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACnE,YAAY,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC1D,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACtI,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACtG,YAAY,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7H,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,YAAY,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AACzE,YAAY,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,23 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
18
|
-
var
|
|
19
|
-
Object.defineProperty(exports, "RubricClient", { enumerable: true, get: function () { return
|
|
20
|
-
Object.defineProperty(exports, "
|
|
21
|
-
|
|
22
|
-
|
|
3
|
+
exports.RubricOpenAIClient = exports.withRubric = exports.RubricLangChainHandler = exports.BackgroundQueue = exports.loadKeyPair = exports.saveKeyPair = exports.loadOrCreateKeyPair = exports.verifySignedPayload = exports.signPayload = exports.generateKeyPair = exports.resetUpgradeManager = exports.getUpgradeManager = exports.ProofUpgradeManager = exports.STAGE_METADATA = exports.LiveProof = exports.createRubricClient = exports.RubricClient = void 0;
|
|
4
|
+
var rubric_client_1 = require("./rubric-client");
|
|
5
|
+
Object.defineProperty(exports, "RubricClient", { enumerable: true, get: function () { return rubric_client_1.RubricClient; } });
|
|
6
|
+
Object.defineProperty(exports, "createRubricClient", { enumerable: true, get: function () { return rubric_client_1.createRubricClient; } });
|
|
7
|
+
var proof_types_1 = require("./proof-types");
|
|
8
|
+
Object.defineProperty(exports, "LiveProof", { enumerable: true, get: function () { return proof_types_1.LiveProof; } });
|
|
9
|
+
Object.defineProperty(exports, "STAGE_METADATA", { enumerable: true, get: function () { return proof_types_1.STAGE_METADATA; } });
|
|
10
|
+
var proof_upgrade_manager_1 = require("./proof-upgrade-manager");
|
|
11
|
+
Object.defineProperty(exports, "ProofUpgradeManager", { enumerable: true, get: function () { return proof_upgrade_manager_1.ProofUpgradeManager; } });
|
|
12
|
+
Object.defineProperty(exports, "getUpgradeManager", { enumerable: true, get: function () { return proof_upgrade_manager_1.getUpgradeManager; } });
|
|
13
|
+
Object.defineProperty(exports, "resetUpgradeManager", { enumerable: true, get: function () { return proof_upgrade_manager_1.resetUpgradeManager; } });
|
|
14
|
+
var signing_1 = require("./signing");
|
|
15
|
+
Object.defineProperty(exports, "generateKeyPair", { enumerable: true, get: function () { return signing_1.generateKeyPair; } });
|
|
16
|
+
Object.defineProperty(exports, "signPayload", { enumerable: true, get: function () { return signing_1.signPayload; } });
|
|
17
|
+
Object.defineProperty(exports, "verifySignedPayload", { enumerable: true, get: function () { return signing_1.verifySignedPayload; } });
|
|
18
|
+
Object.defineProperty(exports, "loadOrCreateKeyPair", { enumerable: true, get: function () { return signing_1.loadOrCreateKeyPair; } });
|
|
19
|
+
Object.defineProperty(exports, "saveKeyPair", { enumerable: true, get: function () { return signing_1.saveKeyPair; } });
|
|
20
|
+
Object.defineProperty(exports, "loadKeyPair", { enumerable: true, get: function () { return signing_1.loadKeyPair; } });
|
|
21
|
+
var background_queue_1 = require("./background-queue");
|
|
22
|
+
Object.defineProperty(exports, "BackgroundQueue", { enumerable: true, get: function () { return background_queue_1.BackgroundQueue; } });
|
|
23
|
+
var langchain_1 = require("./plugins/langchain");
|
|
24
|
+
Object.defineProperty(exports, "RubricLangChainHandler", { enumerable: true, get: function () { return langchain_1.RubricLangChainHandler; } });
|
|
25
|
+
var openai_plugin_1 = require("./plugins/openai-plugin");
|
|
26
|
+
Object.defineProperty(exports, "withRubric", { enumerable: true, get: function () { return openai_plugin_1.withRubric; } });
|
|
27
|
+
Object.defineProperty(exports, "RubricOpenAIClient", { enumerable: true, get: function () { return openai_plugin_1.RubricOpenAIClient; } });
|
|
23
28
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;AAAA,iDAAmE;AAA1D,6GAAA,YAAY,OAAA;AAAE,mHAAA,kBAAkB,OAAA;AAEzC,6CAA0D;AAAjD,wGAAA,SAAS,OAAA;AAAE,6GAAA,cAAc,OAAA;AAElC,iEAAsG;AAA7F,4HAAA,mBAAmB,OAAA;AAAE,0HAAA,iBAAiB,OAAA;AAAE,4HAAA,mBAAmB,OAAA;AAEpE,qCAA6H;AAApH,0GAAA,eAAe,OAAA;AAAE,sGAAA,WAAW,OAAA;AAAE,8GAAA,mBAAmB,OAAA;AAAE,8GAAA,mBAAmB,OAAA;AAAE,sGAAA,WAAW,OAAA;AAAE,sGAAA,WAAW,OAAA;AAEzG,uDAAqD;AAA5C,mHAAA,eAAe,OAAA;AAExB,iDAA6D;AAApD,mHAAA,sBAAsB,OAAA;AAE/B,yDAAyE;AAAhE,2GAAA,UAAU,OAAA;AAAE,mHAAA,kBAAkB,OAAA"}
|