@rubric-protocol/sdk 1.0.1
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/dist/index.d.ts +126 -0
- package/dist/index.js +117 -0
- package/example.ts +39 -0
- package/index.ts +192 -0
- package/package.json +21 -0
- package/tsconfig.json +14 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
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;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* RUBRIC PROTOCOL SDK
|
|
4
|
+
* AI Attestation Infrastructure — EU AI Act Article 12 Compliance
|
|
5
|
+
* Rubric Protocol
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.RubricClient = void 0;
|
|
9
|
+
class RubricClient {
|
|
10
|
+
constructor(config) {
|
|
11
|
+
this.baseUrl = config.baseUrl.replace(/\/$/, '');
|
|
12
|
+
this.apiKey = config.apiKey;
|
|
13
|
+
}
|
|
14
|
+
async request(method, path, body) {
|
|
15
|
+
const headers = { 'Content-Type': 'application/json' };
|
|
16
|
+
if (this.apiKey)
|
|
17
|
+
headers['x-api-key'] = this.apiKey;
|
|
18
|
+
const opts = { method, headers };
|
|
19
|
+
if (body)
|
|
20
|
+
opts.body = JSON.stringify(body);
|
|
21
|
+
const res = await fetch(`${this.baseUrl}${path}`, opts);
|
|
22
|
+
if (!res.ok) {
|
|
23
|
+
const err = await res.json().catch(() => ({ error: res.statusText }));
|
|
24
|
+
throw new Error(err.error || `HTTP ${res.status}`);
|
|
25
|
+
}
|
|
26
|
+
return res.json();
|
|
27
|
+
}
|
|
28
|
+
// ── Health ──
|
|
29
|
+
async health() { return this.request('GET', '/'); }
|
|
30
|
+
async stats() { return this.request('GET', '/v1/stats'); }
|
|
31
|
+
// ── Agents ──
|
|
32
|
+
async registerAgent(name, capabilities, endpoint) {
|
|
33
|
+
return this.request('POST', '/v1/agents', { name, capabilities, endpoint });
|
|
34
|
+
}
|
|
35
|
+
async listAgents(capability) {
|
|
36
|
+
const q = capability ? `?capability=${capability}` : '';
|
|
37
|
+
return this.request('GET', `/v1/agents${q}`);
|
|
38
|
+
}
|
|
39
|
+
async getAgent(agentId) {
|
|
40
|
+
return this.request('GET', `/v1/agents/${agentId}`);
|
|
41
|
+
}
|
|
42
|
+
async deregisterAgent(agentId) {
|
|
43
|
+
return this.request('DELETE', `/v1/agents/${agentId}`);
|
|
44
|
+
}
|
|
45
|
+
async getReputation(agentId) {
|
|
46
|
+
return this.request('GET', `/v1/agents/${agentId}/reputation`);
|
|
47
|
+
}
|
|
48
|
+
async leaderboard() {
|
|
49
|
+
return this.request('GET', '/v1/leaderboard');
|
|
50
|
+
}
|
|
51
|
+
// ── Tasks ──
|
|
52
|
+
async submitTask(type, description, input) {
|
|
53
|
+
return this.request('POST', '/v1/tasks', { type, description, input });
|
|
54
|
+
}
|
|
55
|
+
async listTasks() {
|
|
56
|
+
return this.request('GET', '/v1/tasks');
|
|
57
|
+
}
|
|
58
|
+
async getTask(taskId) {
|
|
59
|
+
return this.request('GET', `/v1/tasks/${taskId}`);
|
|
60
|
+
}
|
|
61
|
+
async placeBid(taskId, agentId, cost, estimatedTime, confidence) {
|
|
62
|
+
return this.request('POST', `/v1/tasks/${taskId}/bid`, { agentId, cost, estimatedTime, confidence });
|
|
63
|
+
}
|
|
64
|
+
async assignTask(taskId) {
|
|
65
|
+
return this.request('POST', `/v1/tasks/${taskId}/assign`, {});
|
|
66
|
+
}
|
|
67
|
+
async submitResult(taskId, agentId, output, executionTime) {
|
|
68
|
+
return this.request('POST', `/v1/tasks/${taskId}/result`, { agentId, output, executionTime });
|
|
69
|
+
}
|
|
70
|
+
// ── Pipelines ──
|
|
71
|
+
async createPipeline(name, steps) {
|
|
72
|
+
return this.request('POST', '/v1/pipelines', { name, steps });
|
|
73
|
+
}
|
|
74
|
+
async listPipelines() {
|
|
75
|
+
return this.request('GET', '/v1/pipelines');
|
|
76
|
+
}
|
|
77
|
+
async getPipeline(pipelineId) {
|
|
78
|
+
return this.request('GET', `/v1/pipelines/${pipelineId}`);
|
|
79
|
+
}
|
|
80
|
+
async startPipeline(pipelineId, input) {
|
|
81
|
+
return this.request('POST', `/v1/pipelines/${pipelineId}/start`, { input });
|
|
82
|
+
}
|
|
83
|
+
async completeStep(pipelineId, agentId, output, executionTime) {
|
|
84
|
+
return this.request('POST', `/v1/pipelines/${pipelineId}/step-result`, { agentId, output, executionTime });
|
|
85
|
+
}
|
|
86
|
+
// ── Proof ──
|
|
87
|
+
async verify(sequenceNumber) {
|
|
88
|
+
return this.request('GET', `/v1/proof/${sequenceNumber}`);
|
|
89
|
+
}
|
|
90
|
+
// ── Events ──
|
|
91
|
+
async events(limit = 50, type) {
|
|
92
|
+
const params = [`limit=${limit}`];
|
|
93
|
+
if (type)
|
|
94
|
+
params.push(`type=${type}`);
|
|
95
|
+
return this.request('GET', `/v1/events?${params.join('&')}`);
|
|
96
|
+
}
|
|
97
|
+
// ── Convenience: Run full task lifecycle ──
|
|
98
|
+
async runTask(agentId, type, description, output, executionTime = 2000) {
|
|
99
|
+
const task = await this.submitTask(type, description);
|
|
100
|
+
await this.placeBid(task.taskId, agentId, 500, 3000, 0.95);
|
|
101
|
+
await this.assignTask(task.taskId);
|
|
102
|
+
return this.submitResult(task.taskId, agentId, output, executionTime);
|
|
103
|
+
}
|
|
104
|
+
// ── Convenience: Run full pipeline ──
|
|
105
|
+
async runPipeline(name, steps, input) {
|
|
106
|
+
const pipeline = await this.createPipeline(name, steps.map(s => ({ type: s.type, capability: s.capability, description: s.description })));
|
|
107
|
+
await this.startPipeline(pipeline.pipelineId, input);
|
|
108
|
+
let result;
|
|
109
|
+
for (const step of steps) {
|
|
110
|
+
result = await this.completeStep(pipeline.pipelineId, 'sdk-auto', step.output, 2000);
|
|
111
|
+
}
|
|
112
|
+
return { pipeline: await this.getPipeline(pipeline.pipelineId), attestations: result.attestations || [] };
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
exports.RubricClient = RubricClient;
|
|
116
|
+
// Default export
|
|
117
|
+
exports.default = RubricClient;
|
package/example.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { RubricClient } from './index';
|
|
2
|
+
|
|
3
|
+
const tempus = new RubricClient({
|
|
4
|
+
baseUrl: 'http://155.138.228.65/forge',
|
|
5
|
+
apiKey: 'rubric-dev-key-2026'
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
async function main() {
|
|
9
|
+
// Register an agent
|
|
10
|
+
const agent = await tempus.registerAgent('MyBot', [
|
|
11
|
+
{ name: 'analysis', description: 'Data analysis' }
|
|
12
|
+
], 'http://localhost:8080');
|
|
13
|
+
console.log('Agent:', agent.name, agent.agentId);
|
|
14
|
+
|
|
15
|
+
// Run a single task (full lifecycle)
|
|
16
|
+
const result = await tempus.runTask(
|
|
17
|
+
agent.agentId, 'analysis', 'HBAR trend check',
|
|
18
|
+
{ trend: 'bullish', confidence: 0.9 }
|
|
19
|
+
);
|
|
20
|
+
console.log('Result attested on HCS #' + result.attestationId);
|
|
21
|
+
|
|
22
|
+
// Verify the proof
|
|
23
|
+
const proof = await tempus.verify(result.attestationId);
|
|
24
|
+
console.log('Verified:', proof.verified, '| Topic:', proof.topic);
|
|
25
|
+
|
|
26
|
+
// Run a pipeline
|
|
27
|
+
const { attestations } = await tempus.runPipeline('SDK Demo', [
|
|
28
|
+
{ type: 'collect', capability: 'research', description: 'Gather data', output: { data: [1,2,3] } },
|
|
29
|
+
{ type: 'analyze', capability: 'analysis', description: 'Analyze', output: { trend: 'up' } },
|
|
30
|
+
{ type: 'report', capability: 'writing', description: 'Write report', output: { report: 'HBAR bullish' } }
|
|
31
|
+
]);
|
|
32
|
+
console.log('Pipeline complete! HCS attestations:', attestations);
|
|
33
|
+
|
|
34
|
+
// Check leaderboard
|
|
35
|
+
const board = await tempus.leaderboard();
|
|
36
|
+
console.log('Leaderboard:', board.data);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
main().catch(console.error);
|
package/index.ts
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RUBRIC PROTOCOL SDK
|
|
3
|
+
* AI Attestation Infrastructure — EU AI Act Article 12 Compliance
|
|
4
|
+
* Rubric Protocol
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export interface RubricConfig {
|
|
8
|
+
baseUrl: string;
|
|
9
|
+
apiKey: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface Agent {
|
|
13
|
+
agentId: string;
|
|
14
|
+
name: string;
|
|
15
|
+
capabilities: { name: string; description: string }[];
|
|
16
|
+
endpoint: string;
|
|
17
|
+
status: string;
|
|
18
|
+
reputation: { tasksCompleted: number; successRate: number; score?: number };
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface Task {
|
|
22
|
+
taskId: string;
|
|
23
|
+
type: string;
|
|
24
|
+
description: string;
|
|
25
|
+
status: string;
|
|
26
|
+
bids: Bid[];
|
|
27
|
+
assignment: any;
|
|
28
|
+
result: TaskResult | null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface Bid {
|
|
32
|
+
bidId: string;
|
|
33
|
+
agentId: string;
|
|
34
|
+
cost: number;
|
|
35
|
+
estimatedTime: number;
|
|
36
|
+
confidence: number;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface TaskResult {
|
|
40
|
+
agentId: string;
|
|
41
|
+
output: any;
|
|
42
|
+
executionTime: number;
|
|
43
|
+
completedAt: string;
|
|
44
|
+
attestationId: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface Pipeline {
|
|
48
|
+
pipelineId: string;
|
|
49
|
+
name: string;
|
|
50
|
+
status: string;
|
|
51
|
+
steps: PipelineStep[];
|
|
52
|
+
attestations: string[];
|
|
53
|
+
completedAt?: string;
|
|
54
|
+
}
|
|
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
|
+
|
|
65
|
+
export interface Proof {
|
|
66
|
+
sequenceNumber: string;
|
|
67
|
+
topic: string;
|
|
68
|
+
explorer: string;
|
|
69
|
+
task: any;
|
|
70
|
+
pipeline: any;
|
|
71
|
+
verified: boolean;
|
|
72
|
+
network: string;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export class RubricClient {
|
|
76
|
+
private baseUrl: string;
|
|
77
|
+
private apiKey: string;
|
|
78
|
+
|
|
79
|
+
constructor(config: RubricConfig) {
|
|
80
|
+
this.baseUrl = config.baseUrl.replace(/\/$/, '');
|
|
81
|
+
this.apiKey = config.apiKey;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
private async request(method: string, path: string, body?: any): Promise<any> {
|
|
85
|
+
const headers: Record<string, string> = { 'Content-Type': 'application/json' };
|
|
86
|
+
if (this.apiKey) headers['x-api-key'] = this.apiKey;
|
|
87
|
+
const opts: RequestInit = { method, headers };
|
|
88
|
+
if (body) opts.body = JSON.stringify(body);
|
|
89
|
+
const res = await fetch(`${this.baseUrl}${path}`, opts);
|
|
90
|
+
if (!res.ok) {
|
|
91
|
+
const err = await res.json().catch(() => ({ error: res.statusText }));
|
|
92
|
+
throw new Error(err.error || `HTTP ${res.status}`);
|
|
93
|
+
}
|
|
94
|
+
return res.json();
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// ── Health ──
|
|
98
|
+
async health() { return this.request('GET', '/'); }
|
|
99
|
+
async stats() { return this.request('GET', '/v1/stats'); }
|
|
100
|
+
|
|
101
|
+
// ── Agents ──
|
|
102
|
+
async registerAgent(name: string, capabilities: { name: string; description: string }[], endpoint: string): Promise<Agent> {
|
|
103
|
+
return this.request('POST', '/v1/agents', { name, capabilities, endpoint });
|
|
104
|
+
}
|
|
105
|
+
async listAgents(capability?: string): Promise<{ data: Agent[]; total: number }> {
|
|
106
|
+
const q = capability ? `?capability=${capability}` : '';
|
|
107
|
+
return this.request('GET', `/v1/agents${q}`);
|
|
108
|
+
}
|
|
109
|
+
async getAgent(agentId: string): Promise<Agent> {
|
|
110
|
+
return this.request('GET', `/v1/agents/${agentId}`);
|
|
111
|
+
}
|
|
112
|
+
async deregisterAgent(agentId: string) {
|
|
113
|
+
return this.request('DELETE', `/v1/agents/${agentId}`);
|
|
114
|
+
}
|
|
115
|
+
async getReputation(agentId: string) {
|
|
116
|
+
return this.request('GET', `/v1/agents/${agentId}/reputation`);
|
|
117
|
+
}
|
|
118
|
+
async leaderboard() {
|
|
119
|
+
return this.request('GET', '/v1/leaderboard');
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// ── Tasks ──
|
|
123
|
+
async submitTask(type: string, description: string, input?: any): Promise<Task> {
|
|
124
|
+
return this.request('POST', '/v1/tasks', { type, description, input });
|
|
125
|
+
}
|
|
126
|
+
async listTasks(): Promise<{ data: Task[]; total: number }> {
|
|
127
|
+
return this.request('GET', '/v1/tasks');
|
|
128
|
+
}
|
|
129
|
+
async getTask(taskId: string): Promise<Task> {
|
|
130
|
+
return this.request('GET', `/v1/tasks/${taskId}`);
|
|
131
|
+
}
|
|
132
|
+
async placeBid(taskId: string, agentId: string, cost: number, estimatedTime: number, confidence: number): Promise<Bid> {
|
|
133
|
+
return this.request('POST', `/v1/tasks/${taskId}/bid`, { agentId, cost, estimatedTime, confidence });
|
|
134
|
+
}
|
|
135
|
+
async assignTask(taskId: string) {
|
|
136
|
+
return this.request('POST', `/v1/tasks/${taskId}/assign`, {});
|
|
137
|
+
}
|
|
138
|
+
async submitResult(taskId: string, agentId: string, output: any, executionTime: number): Promise<TaskResult> {
|
|
139
|
+
return this.request('POST', `/v1/tasks/${taskId}/result`, { agentId, output, executionTime });
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// ── Pipelines ──
|
|
143
|
+
async createPipeline(name: string, steps: { type: string; capability: string; description: string }[]): Promise<Pipeline> {
|
|
144
|
+
return this.request('POST', '/v1/pipelines', { name, steps });
|
|
145
|
+
}
|
|
146
|
+
async listPipelines(): Promise<{ data: Pipeline[]; total: number }> {
|
|
147
|
+
return this.request('GET', '/v1/pipelines');
|
|
148
|
+
}
|
|
149
|
+
async getPipeline(pipelineId: string): Promise<Pipeline> {
|
|
150
|
+
return this.request('GET', `/v1/pipelines/${pipelineId}`);
|
|
151
|
+
}
|
|
152
|
+
async startPipeline(pipelineId: string, input?: any) {
|
|
153
|
+
return this.request('POST', `/v1/pipelines/${pipelineId}/start`, { input });
|
|
154
|
+
}
|
|
155
|
+
async completeStep(pipelineId: string, agentId: string, output: any, executionTime: number) {
|
|
156
|
+
return this.request('POST', `/v1/pipelines/${pipelineId}/step-result`, { agentId, output, executionTime });
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// ── Proof ──
|
|
160
|
+
async verify(sequenceNumber: string): Promise<Proof> {
|
|
161
|
+
return this.request('GET', `/v1/proof/${sequenceNumber}`);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// ── Events ──
|
|
165
|
+
async events(limit = 50, type?: string) {
|
|
166
|
+
const params = [`limit=${limit}`];
|
|
167
|
+
if (type) params.push(`type=${type}`);
|
|
168
|
+
return this.request('GET', `/v1/events?${params.join('&')}`);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// ── Convenience: Run full task lifecycle ──
|
|
172
|
+
async runTask(agentId: string, type: string, description: string, output: any, executionTime = 2000): Promise<TaskResult> {
|
|
173
|
+
const task = await this.submitTask(type, description);
|
|
174
|
+
await this.placeBid(task.taskId, agentId, 500, 3000, 0.95);
|
|
175
|
+
await this.assignTask(task.taskId);
|
|
176
|
+
return this.submitResult(task.taskId, agentId, output, executionTime);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// ── Convenience: Run full pipeline ──
|
|
180
|
+
async runPipeline(name: string, steps: { type: string; capability: string; description: string; output: any }[], input?: any): Promise<{ pipeline: Pipeline; attestations: string[] }> {
|
|
181
|
+
const pipeline = await this.createPipeline(name, steps.map(s => ({ type: s.type, capability: s.capability, description: s.description })));
|
|
182
|
+
await this.startPipeline(pipeline.pipelineId, input);
|
|
183
|
+
let result: any;
|
|
184
|
+
for (const step of steps) {
|
|
185
|
+
result = await this.completeStep(pipeline.pipelineId, 'sdk-auto', step.output, 2000);
|
|
186
|
+
}
|
|
187
|
+
return { pipeline: await this.getPipeline(pipeline.pipelineId), attestations: result.attestations || [] };
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// Default export
|
|
192
|
+
export default RubricClient;
|
package/package.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rubric-protocol/sdk",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Rubric Protocol SDK — AI agent coordination on Hedera",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"author": "Rubric Protocol",
|
|
9
|
+
"repository": "https://github.com/rubric-protocol/sdk",
|
|
10
|
+
"keywords": [
|
|
11
|
+
"hedera",
|
|
12
|
+
"hcs",
|
|
13
|
+
"ai-attestation",
|
|
14
|
+
"eu-ai-act",
|
|
15
|
+
"blockchain"
|
|
16
|
+
],
|
|
17
|
+
"dependencies": {},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"typescript": "^5.0.0"
|
|
20
|
+
}
|
|
21
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"declaration": true,
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
"rootDir": "./",
|
|
8
|
+
"strict": false,
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
"esModuleInterop": true
|
|
11
|
+
},
|
|
12
|
+
"include": ["index.ts"],
|
|
13
|
+
"exclude": ["node_modules", "dist", "example.ts"]
|
|
14
|
+
}
|