@oro-ai/sdk 0.6.8

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,206 @@
1
+ # ORO SDK for TypeScript
2
+
3
+ Official TypeScript SDK for the ORO Bittensor Subnet API.
4
+
5
+ This SDK is auto-generated from the OpenAPI specification using [@hey-api/openapi-ts](https://github.com/hey-api/openapi-ts).
6
+
7
+ ## Installation
8
+
9
+ This package is hosted on GitHub Packages. First, configure npm to use GitHub Packages for the `@oro-ai` scope.
10
+
11
+ **1. Create a GitHub Personal Access Token** with `read:packages` scope at https://github.com/settings/tokens
12
+
13
+ **2. Add to your project's `.npmrc`:**
14
+
15
+ ```
16
+ @oro-ai:registry=https://npm.pkg.github.com
17
+ //npm.pkg.github.com/:_authToken=YOUR_GITHUB_TOKEN
18
+ ```
19
+
20
+ Or authenticate via npm login:
21
+ ```bash
22
+ npm login --scope=@oro-ai --registry=https://npm.pkg.github.com
23
+ ```
24
+
25
+ **3. Install the package:**
26
+
27
+ ```bash
28
+ npm install @oro-ai/sdk @hey-api/client-fetch
29
+ ```
30
+
31
+ ## Quick Start
32
+
33
+ ### Public API (No Auth Required)
34
+
35
+ ```typescript
36
+ import { configurePublicClient, getLeaderboard, getTopAgent } from '@oro-ai/sdk';
37
+
38
+ // Configure the client
39
+ configurePublicClient('https://api.oro.ai');
40
+
41
+ // Get leaderboard
42
+ const { data: leaderboard } = await getLeaderboard();
43
+ leaderboard?.entries.forEach(entry => {
44
+ console.log(`${entry.rank}. ${entry.miner_hotkey}: ${entry.final_score}`);
45
+ });
46
+
47
+ // Get top agent for emissions
48
+ const { data: top } = await getTopAgent();
49
+ if (top) {
50
+ console.log(`Top miner: ${top.top_miner_hotkey} with score ${top.top_score}`);
51
+ }
52
+ ```
53
+
54
+ ### Authenticated API (Validators/Miners)
55
+
56
+ Use `configureBittensorAuth` to automatically sign all requests:
57
+
58
+ ```typescript
59
+ import { configureBittensorAuth, claimWork, heartbeat, completeRun } from '@oro-ai/sdk';
60
+
61
+ // Configure with your wallet's signing function
62
+ configureBittensorAuth('https://api.oro.ai', {
63
+ hotkey: '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY',
64
+ sign: (message) => {
65
+ // Sign the message with your Bittensor wallet
66
+ // Returns signature as hex string
67
+ return wallet.sign(message);
68
+ },
69
+ });
70
+
71
+ // All requests are now automatically authenticated!
72
+
73
+ // Validator: Claim work
74
+ const { data: work } = await claimWork();
75
+ if (work) {
76
+ console.log(`Claimed eval run: ${work.eval_run_id}`);
77
+
78
+ // Send heartbeat
79
+ const { data: hb } = await heartbeat({ path: { eval_run_id: work.eval_run_id } });
80
+ console.log(`Lease extended to: ${hb?.lease_expires_at}`);
81
+
82
+ // Complete run
83
+ const { data: result } = await completeRun({
84
+ path: { eval_run_id: work.eval_run_id },
85
+ body: {
86
+ terminal_status: 'SUCCESS',
87
+ validator_score: 0.85,
88
+ },
89
+ });
90
+ console.log(`Completed! Eligible: ${result?.agent_version_became_eligible}`);
91
+ }
92
+ ```
93
+
94
+ ### Miner API
95
+
96
+ ```typescript
97
+ import { configureBittensorAuth, submitAgent, getOwnedAgentVersionStatus } from '@oro-ai/sdk';
98
+
99
+ // Configure auth
100
+ configureBittensorAuth('https://api.oro.ai', {
101
+ hotkey: minerHotkey,
102
+ sign: (message) => minerWallet.sign(message),
103
+ });
104
+
105
+ // Submit an agent
106
+ const file = new File([agentCode], 'agent.py', { type: 'text/x-python' });
107
+ const { data: response } = await submitAgent({
108
+ body: { file },
109
+ });
110
+
111
+ if (response?.admission_status === 'ACCEPTED') {
112
+ console.log(`Submitted! Version ID: ${response.agent_version_id}`);
113
+
114
+ // Check status
115
+ const { data: status } = await getOwnedAgentVersionStatus({
116
+ path: { agent_version_id: response.agent_version_id },
117
+ });
118
+ console.log(`State: ${status?.state}, Score: ${status?.final_score}`);
119
+ }
120
+ ```
121
+
122
+ ## Auth Helpers
123
+
124
+ ### `configureBittensorAuth(baseUrl, config)`
125
+
126
+ Configures the client with automatic Bittensor authentication.
127
+
128
+ ```typescript
129
+ import { configureBittensorAuth } from '@oro-ai/sdk';
130
+
131
+ configureBittensorAuth('https://api.oro.ai', {
132
+ hotkey: '5GrwvaEF...', // Your SS58 hotkey address
133
+ sign: async (message) => { // Signs "nonce:timestamp" format
134
+ return wallet.sign(message);
135
+ },
136
+ });
137
+ ```
138
+
139
+ ### `configurePublicClient(baseUrl)`
140
+
141
+ Configures the client for public (unauthenticated) endpoints only.
142
+
143
+ ```typescript
144
+ import { configurePublicClient } from '@oro-ai/sdk';
145
+
146
+ configurePublicClient('https://api.oro.ai');
147
+ ```
148
+
149
+ ### `generateAuthHeaders(config, nonce?)`
150
+
151
+ Generates auth headers manually if needed.
152
+
153
+ ```typescript
154
+ import { generateAuthHeaders } from '@oro-ai/sdk';
155
+
156
+ const headers = await generateAuthHeaders({
157
+ hotkey: '5GrwvaEF...',
158
+ sign: (msg) => wallet.sign(msg),
159
+ });
160
+ // { 'X-Hotkey': '...', 'X-Signature': '...', 'X-Nonce': '...', 'X-Timestamp': '...' }
161
+ ```
162
+
163
+ ## API Structure
164
+
165
+ All SDK functions follow the pattern:
166
+ ```typescript
167
+ const { data, error, response } = await functionName({ path?, query?, body? });
168
+ ```
169
+
170
+ - `data` - Parsed response body (typed)
171
+ - `error` - Error object if request failed
172
+ - `response` - Raw fetch Response object
173
+
174
+ ## Development
175
+
176
+ ### Running Tests
177
+
178
+ ```bash
179
+ # Install dependencies
180
+ npm install
181
+
182
+ # Run tests
183
+ npm test
184
+
185
+ # Run tests in watch mode
186
+ npm run test:watch
187
+ ```
188
+
189
+ ### Regenerating the SDK
190
+
191
+ When the API changes:
192
+
193
+ ```bash
194
+ cd packages/typescript
195
+ npm run generate
196
+ ```
197
+
198
+ Or from the repo root:
199
+
200
+ ```bash
201
+ ./scripts/generate-typescript.sh
202
+ ```
203
+
204
+ ## License
205
+
206
+ MIT