@rubric-protocol/sdk 1.0.1 → 1.0.2

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,218 @@
1
+ # @rubric-protocol/sdk
2
+
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
+
5
+ Built for [EU AI Act Article 12](https://rubric-protocol.com) compliance and beyond.
6
+
7
+ ---
8
+
9
+ ## How it works
10
+
11
+ 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.
12
+
13
+ ```
14
+ AI decision ‒ local sign (<1ms) → proof returned immediately
15
+ ↓ background
16
+ Rubric anchor (5-10s) → HCS confirmed (~30s)
17
+ ```
18
+
19
+ Each proof upgrades automatically as anchoring completes. You can fire-and-forget, or await full HCS confirmation for high-stakes decisions.
20
+
21
+ ---
22
+
23
+ ## Install
24
+
25
+ ```bash
26
+ npm install @rubric-protocol/sdk
27
+ ```
28
+
29
+ Peer dependencies (install only what you use):
30
+
31
+ ```bash
32
+ npm install openai # for OpenAI plugin
33
+ npm install @langchain/core # for LangChain plugin
34
+ ```
35
+
36
+ ---
37
+
38
+ ## Quickstart
39
+
40
+ ```typescript
41
+ import { createRubricClient } from '@rubric-protocol/sdk';
42
+
43
+ const rubric = createRubricClient({
44
+ apiKey: process.env.RUBRIC_API_KEY!,
45
+ localSigning: true, // sign locally before network
46
+ backgroundQueue: true, // non-blocking flush
47
+ node: 'auto', // route to nearest healthy node
48
+ });
49
+
50
+ const proof = await rubric.attest({
51
+ agentId: 'my-agent-v1',
52
+ output: 'Loan application approved. Score: 742, DTI: 28%.',
53
+ leafType: 'AGENT_OUTPUT',
54
+ metadata: { model: 'gpt-4o', pipeline: 'credit-decisioning' },
55
+ });
56
+
57
+ console.log(proof.attestationId); // immediate
58
+ console.log(proof.stage); // 'local'
59
+
60
+ // Optional: wait for full HCS confirmation
61
+ proof.onUpgrade('confirmed', (confirmed) => {
62
+ console.log(confirmed.hashScanUrl); // publicly verifiable on HashScan
63
+ });
64
+ ```
65
+
66
+ ---
67
+
68
+ ## LangChain
69
+
70
+ Add one handler and every LLM call, agent action, chain, and tool invocation is automatically attested.
71
+
72
+ ```typescript
73
+ import { ChatOpenAI } from '@langchain/openai';
74
+ import { AgentExecutor } from 'langchain/agents';
75
+ import { RubricLangChainHandler } from '@rubric-protocol/sdk';
76
+
77
+ const rubric = new RubricLangChainHandler({
78
+ apiKey: process.env.RUBRIC_API_KEY!,
79
+ localSigning: true,
80
+ backgroundQueue: true,
81
+ events: ['llm', 'agent', 'tool'], // choose what to attest
82
+ pipelineId: 'my-pipeline',
83
+ });
84
+
85
+ const executor = await AgentExecutor.fromAgentAndTools({
86
+ agent,
87
+ tools,
88
+ callbacks: [rubric], // that's it
89
+ });
90
+
91
+ await executor.invoke({ input: 'Analyze this transaction for fraud.' });
92
+ await rubric.shutdown(); // flush remaining queue on exit
93
+ ```
94
+
95
+ ---
96
+
97
+ ## OpenAI
98
+
99
+ Drop-in wrapper — your existing code is unchanged.
100
+
101
+ ```typescript
102
+ import OpenAI from 'openai';
103
+ import { withRubric } from '@rubric-protocol/sdk';
104
+
105
+ const openai = withRubric(new OpenAI(), {
106
+ apiKey: process.env.RUBRIC_API_KEY!,
107
+ agentId: 'my-openai-agent',
108
+ localSigning: true,
109
+ backgroundQueue: true,
110
+ });
111
+
112
+ // Use exactly as before — attestation happens automatically
113
+ const completion = await openai.chat.completions.create({
114
+ model: 'gpt-4o',
115
+ messages: [{ role: 'user', content: 'Should we approve this claim?' }],
116
+ });
117
+ ```
118
+
119
+ ---
120
+
121
+ ## High-stakes decisions
122
+
123
+ For decisions requiring immediate confirmation (medical triage, credit denial, hiring rejection), await full HCS anchoring:
124
+
125
+ ```typescript
126
+ const confirmed = await rubric.attestAndConfirm({
127
+ agentId: 'triage-agent',
128
+ output: 'Patient flagged for immediate review.',
129
+ leafType: 'AGENT_OUTPUT',
130
+ risk: 'high',
131
+ }, 90_000); // timeout ms
132
+
133
+ console.log(confirmed.hcsSequenceNumber);
134
+ console.log(confirmed.hashScanUrl); // immutable public record
135
+ ```
136
+
137
+ ---
138
+
139
+ ## Proof lifecycle
140
+
141
+ Every attestation returns a `LiveProof` that upgrades automatically:
142
+
143
+ | Stage | When | What you have |
144
+ |---|---|---|
145
+ | `local` | <1ms | ML-DSA-65 signature + timestamp |
146
+ | `anchored` | 5–10s | Merkle root committed to Rubric |
147
+ | `confirmed` | ~30s | HCS sequence number, HashScan URL |
148
+
149
+ ```typescript
150
+ proof.onUpgrade('anchored', (p) => console.log(p.merkleRoot));
151
+ proof.onUpgrade('confirmed', (p) => console.log(p.hashScanUrl));
152
+ proof.onUpgrade('any', (p) => console.log(p.stage)); // fires on each upgrade
153
+ ```
154
+
155
+ ---
156
+
157
+ ## Configuration
158
+
159
+ ```typescript
160
+ createRubricClient({
161
+ apiKey: string, // required — get one at rubric-protocol.com
162
+ node?: 'us'|'sg'|'jp'|'ca'|'eu'|'auto', // default: 'us'
163
+ localSigning?: boolean, // default: false
164
+ keystorePath?: string, // default: ~/.rubric/sdk-keypair.json
165
+ keystorePassphrase?: string, // AES-256-GCM encrypts the keystore
166
+ backgroundQueue?: boolean, // default: false
167
+ enterprise?: boolean, // uses /v1/tiered-attest (Merkle batching)
168
+ proofUpgrade?: boolean, // auto-poll for stage upgrades
169
+ timeout?: number, // HTTP timeout ms, default: 15000
170
+ })
171
+ ```
172
+
173
+ ---
174
+
175
+ ## Nodes
176
+
177
+ The SDK routes to Rubric's global federation automatically when `node: 'auto'`.
178
+
179
+ | Region | Endpoint |
180
+ |---|---|
181
+ | US East | `https://rubric-protocol.com/verify` |
182
+ | Singapore | `https://sg.rubric-protocol.com/verify` |
183
+ | Japan | `https://jp.rubric-protocol.com/verify` |
184
+ | Canada | `https://ca.rubric-protocol.com/verify` |
185
+ | EU Central | `https://eu.rubric-protocol.com/verify` |
186
+
187
+ ---
188
+
189
+ ## Security
190
+
191
+ - **ML-DSA-65** (NIST FIPS 204) — post-quantum signature scheme, same algorithm used server-side
192
+ - Keypairs stored at `~/.rubric/sdk-keypair.json` with optional AES-256-GCM encryption via passphrase
193
+ - Canonical JSON serialization ensures deterministic, tamper-evident signing
194
+ - All attestations anchored to [Hedera Consensus Service](https://hedera.com) — public, immutable, independently verifiable
195
+
196
+ ---
197
+
198
+ ## Requirements
199
+
200
+ - Node.js >= 18.0.0
201
+ - TypeScript >= 5.0 (if using TypeScript)
202
+
203
+ ---
204
+
205
+ ## Links
206
+
207
+ - [Documentation](https://rubric-protocol.com)
208
+ - [API Reference](https://rubric-protocol.com/docs)
209
+ - [HashScan](https://hashscan.io/testnet/topic/0.0.8207826) — live attestation stream
210
+ - [EU AI Act Article 12](https://eur-lex.europa.eu/legal-content/EN/TXT/?uri=CELEX:32024R1689)
211
+
212
+ ---
213
+
214
+ ## License
215
+
216
+ MIT — Echelon Intelligence Systems LLC
217
+
218
+ *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"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,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+ /**
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,IAAI;YAC3C,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,EAAE;YACjC,WAAW,EAAE,MAAM,CAAC,WAAW,IAAI,CAAC;YACpC,WAAW,EAAE,MAAM,CAAC,WAAW,IAAI,IAAI;YACvC,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,YAAY,EAAE,MAAM,CAAC,YAAY;YACjC,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,OAAO,EAAE,MAAM,CAAC,OAAO;SACxB,CAAC;QACF,IAAI,IAAI,CAAC,MAAM,CAAC,WAAW;YAAE,IAAI,CAAC,aAAa,EAAE,CAAC;IACpD,CAAC;IACD,OAAO,CAAC,QAAgB,EAAE,OAAgC,EAAE,OAA+B,EAAE,UAAoC,EAAE;QACjI,MAAM,EAAE,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;QAC/B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,WAA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I,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;YAAE,OAAO;QAChF,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC;YAC1E,IAAI,IAAI,CAAC,OAAO,KAAK,CAAC;gBAAE,OAAO;YAC/B,KAAK,MAAM,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAgB;gBAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;YACpF,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,IAAI,EAAE,CAAC;YAC1C,OAAO,CAAC,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,126 +1,15 @@
1
- /**
2
- * RUBRIC PROTOCOL SDK
3
- * AI Attestation Infrastructure EU AI Act Article 12 Compliance
4
- * Rubric Protocol
5
- */
6
- export interface RubricConfig {
7
- baseUrl: string;
8
- apiKey: string;
9
- }
10
- export interface Agent {
11
- agentId: string;
12
- name: string;
13
- capabilities: {
14
- name: string;
15
- description: string;
16
- }[];
17
- endpoint: string;
18
- status: string;
19
- reputation: {
20
- tasksCompleted: number;
21
- successRate: number;
22
- score?: number;
23
- };
24
- }
25
- export interface Task {
26
- taskId: string;
27
- type: string;
28
- description: string;
29
- status: string;
30
- bids: Bid[];
31
- assignment: any;
32
- result: TaskResult | null;
33
- }
34
- export interface Bid {
35
- bidId: string;
36
- agentId: string;
37
- cost: number;
38
- estimatedTime: number;
39
- confidence: number;
40
- }
41
- export interface TaskResult {
42
- agentId: string;
43
- output: any;
44
- executionTime: number;
45
- completedAt: string;
46
- attestationId: string;
47
- }
48
- export interface Pipeline {
49
- pipelineId: string;
50
- name: string;
51
- status: string;
52
- steps: PipelineStep[];
53
- attestations: string[];
54
- completedAt?: string;
55
- }
56
- export interface PipelineStep {
57
- stepIndex: number;
58
- type: string;
59
- description: string;
60
- status: string;
61
- attestationId?: string;
62
- output?: any;
63
- }
64
- export interface Proof {
65
- sequenceNumber: string;
66
- topic: string;
67
- explorer: string;
68
- task: any;
69
- pipeline: any;
70
- verified: boolean;
71
- network: string;
72
- }
73
- export declare class RubricClient {
74
- private baseUrl;
75
- private apiKey;
76
- constructor(config: RubricConfig);
77
- private request;
78
- health(): Promise<any>;
79
- stats(): Promise<any>;
80
- registerAgent(name: string, capabilities: {
81
- name: string;
82
- description: string;
83
- }[], endpoint: string): Promise<Agent>;
84
- listAgents(capability?: string): Promise<{
85
- data: Agent[];
86
- total: number;
87
- }>;
88
- getAgent(agentId: string): Promise<Agent>;
89
- deregisterAgent(agentId: string): Promise<any>;
90
- getReputation(agentId: string): Promise<any>;
91
- leaderboard(): Promise<any>;
92
- submitTask(type: string, description: string, input?: any): Promise<Task>;
93
- listTasks(): Promise<{
94
- data: Task[];
95
- total: number;
96
- }>;
97
- getTask(taskId: string): Promise<Task>;
98
- placeBid(taskId: string, agentId: string, cost: number, estimatedTime: number, confidence: number): Promise<Bid>;
99
- assignTask(taskId: string): Promise<any>;
100
- submitResult(taskId: string, agentId: string, output: any, executionTime: number): Promise<TaskResult>;
101
- createPipeline(name: string, steps: {
102
- type: string;
103
- capability: string;
104
- description: string;
105
- }[]): Promise<Pipeline>;
106
- listPipelines(): Promise<{
107
- data: Pipeline[];
108
- total: number;
109
- }>;
110
- getPipeline(pipelineId: string): Promise<Pipeline>;
111
- startPipeline(pipelineId: string, input?: any): Promise<any>;
112
- completeStep(pipelineId: string, agentId: string, output: any, executionTime: number): Promise<any>;
113
- verify(sequenceNumber: string): Promise<Proof>;
114
- events(limit?: number, type?: string): Promise<any>;
115
- runTask(agentId: string, type: string, description: string, output: any, executionTime?: number): Promise<TaskResult>;
116
- runPipeline(name: string, steps: {
117
- type: string;
118
- capability: string;
119
- description: string;
120
- output: any;
121
- }[], input?: any): Promise<{
122
- pipeline: Pipeline;
123
- attestations: string[];
124
- }>;
125
- }
126
- export default RubricClient;
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 './ml-dsa-local';
8
+ export type { LocalKeyPair, SignedPayload } from './ml-dsa-local';
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';
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
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,gBAAgB,CAAC;AAClI,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAClE,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"}