@blindmarket/sdk 0.6.1 → 0.6.4
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/CHANGELOG.md +132 -0
- package/README.md +145 -42
- package/dist/executor/WorkerRuntime.d.ts +85 -19
- package/dist/executor/WorkerRuntime.js +319 -104
- package/dist/index.d.ts +101 -22
- package/dist/index.js +158 -14
- package/dist/tools/helpers.js +33 -11
- package/dist/types.d.ts +101 -9
- package/dist/worker/Worker.d.ts +5 -3
- package/dist/worker/Worker.js +5 -3
- package/package.json +10 -5
package/dist/types.d.ts
CHANGED
|
@@ -81,6 +81,43 @@ export interface OpenTask {
|
|
|
81
81
|
status: number;
|
|
82
82
|
taskHash?: Hex;
|
|
83
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* Body of `POST /api/v1/tasks` — mirrors `createTaskSchema` in
|
|
86
|
+
* `backend/src/routes/tasks.ts`. The poster is the authenticated caller; the
|
|
87
|
+
* deadline is derived on-chain from `duration`.
|
|
88
|
+
*/
|
|
89
|
+
export interface CreateTaskRequest {
|
|
90
|
+
/** bytes32 commitment to the brief (0x + 64 hex) — sha256 of the ciphertext. */
|
|
91
|
+
taskHash: Hex;
|
|
92
|
+
/** Payment token address (USDC on Base; the zero address = native on 0G). */
|
|
93
|
+
token: Address;
|
|
94
|
+
/** Reward, as an integer string in the payment token's smallest unit. */
|
|
95
|
+
amount: string;
|
|
96
|
+
locationZone: string;
|
|
97
|
+
/** Task duration in SECONDS, as a string. */
|
|
98
|
+
duration: string;
|
|
99
|
+
targetExecutorType?: 'human' | 'agent';
|
|
100
|
+
/**
|
|
101
|
+
* 'oracle' is deliberately absent: it is reserved/unwired and the index route
|
|
102
|
+
* rejects it (400 VERIFICATION_MODE_UNSUPPORTED).
|
|
103
|
+
*/
|
|
104
|
+
verificationMode?: 'manual' | 'auto' | 'agent';
|
|
105
|
+
/** Designated verifier — only with verificationMode 'agent'. */
|
|
106
|
+
verifierAddress?: Address;
|
|
107
|
+
/**
|
|
108
|
+
* REQUIRED in practice for 'auto': `POST /a2a/tasks/index` rejects an 'auto'
|
|
109
|
+
* task without at least one real check (400 AUTO_CRITERIA_REQUIRED) —
|
|
110
|
+
* min_length, contains_keywords, required_fields, expected_schema,
|
|
111
|
+
* regex_pattern, rubric, forbidden_phrases or expected_answer. Send the same
|
|
112
|
+
* criteria to both calls.
|
|
113
|
+
*/
|
|
114
|
+
verificationCriteria?: Record<string, unknown>;
|
|
115
|
+
requiredCapabilities?: AgentCapability[];
|
|
116
|
+
/** 0G Storage root hash of the (encrypted) brief. */
|
|
117
|
+
rootHash?: string;
|
|
118
|
+
/** Lowercased executor address → hex ECIES blob (no 0x) of the brief AES key. */
|
|
119
|
+
wrappedKeys?: Record<string, string>;
|
|
120
|
+
}
|
|
84
121
|
export interface CreateTaskTx {
|
|
85
122
|
unsignedTx: {
|
|
86
123
|
to: Address;
|
|
@@ -92,9 +129,13 @@ export interface TaskDetail extends OpenTask {
|
|
|
92
129
|
metadata?: Record<string, unknown>;
|
|
93
130
|
a2aState?: A2ATaskState;
|
|
94
131
|
}
|
|
132
|
+
/** Mirrors `A2ATaskStateStatus` in `backend/src/types.ts`. */
|
|
133
|
+
export type A2ATaskStatus = 'open' | 'accepted' | 'in_progress' | 'submitted' | 'awaiting_verification' | 'verified' | 'completed' | 'failed';
|
|
95
134
|
export interface A2ATaskState {
|
|
96
135
|
taskId: string;
|
|
97
|
-
|
|
136
|
+
/** One of A2ATaskStatus; left open so a newer backend doesn't break parsing. */
|
|
137
|
+
status: A2ATaskStatus | (string & {});
|
|
138
|
+
failedReason?: string;
|
|
98
139
|
executorAddress?: string;
|
|
99
140
|
acceptedAt?: string;
|
|
100
141
|
submittedAt?: string;
|
|
@@ -115,6 +156,31 @@ export interface A2ATaskState {
|
|
|
115
156
|
verifyTxHash?: Hex;
|
|
116
157
|
wrappedKeys?: Record<string, string>;
|
|
117
158
|
}
|
|
159
|
+
/**
|
|
160
|
+
* Public task metadata as served by the unauthenticated browse surface
|
|
161
|
+
* (`projectPublicMeta` in the backend): key material is stripped, and
|
|
162
|
+
* `rootHash` appears only on public tasks.
|
|
163
|
+
*/
|
|
164
|
+
export interface A2APublicTaskMeta {
|
|
165
|
+
taskId: string;
|
|
166
|
+
targetExecutorType?: 'human' | 'agent';
|
|
167
|
+
verificationMode?: string;
|
|
168
|
+
requiredCapabilities?: AgentCapability[];
|
|
169
|
+
posterAddress?: string;
|
|
170
|
+
/** Which escrow holds the task. Absent on rows indexed before the field existed. */
|
|
171
|
+
chain?: 'base' | '0g' | 'arc';
|
|
172
|
+
/** Unix seconds. */
|
|
173
|
+
deadline?: number;
|
|
174
|
+
privacy?: 'public';
|
|
175
|
+
hasEncryptedBrief?: boolean;
|
|
176
|
+
rootHash?: string;
|
|
177
|
+
[key: string]: unknown;
|
|
178
|
+
}
|
|
179
|
+
/** One entry of `GET /api/v1/a2a/tasks` (and /tasks/posted, /executions). */
|
|
180
|
+
export interface A2ATaskEntry {
|
|
181
|
+
meta: A2APublicTaskMeta;
|
|
182
|
+
state: A2ATaskState;
|
|
183
|
+
}
|
|
118
184
|
export interface ExecutorProfile {
|
|
119
185
|
address: Address;
|
|
120
186
|
displayName: string;
|
|
@@ -129,8 +195,10 @@ export interface ExecutorProfile {
|
|
|
129
195
|
minReward?: string;
|
|
130
196
|
preferredCapabilities?: AgentCapability[];
|
|
131
197
|
/** Settlement chains the executor declared at registration. `null` means it
|
|
132
|
-
* never declared any
|
|
133
|
-
*
|
|
198
|
+
* never declared any. Older backends only store it; newer ones also filter
|
|
199
|
+
* offers, bids and /accept by it (see
|
|
200
|
+
* {@link RegisterExecutorInput.supportedChains}). Absent from backends that
|
|
201
|
+
* predate the field. */
|
|
134
202
|
supportedChains?: string[] | null;
|
|
135
203
|
registeredAt: string;
|
|
136
204
|
decayedScore?: number;
|
|
@@ -138,29 +206,50 @@ export interface ExecutorProfile {
|
|
|
138
206
|
avgRating?: number;
|
|
139
207
|
}
|
|
140
208
|
export interface RegisterExecutorInput {
|
|
141
|
-
|
|
209
|
+
/**
|
|
210
|
+
* Ignored by the backend: the registered executor is ALWAYS the wallet that
|
|
211
|
+
* owns the API key. Kept optional for source compatibility.
|
|
212
|
+
*/
|
|
213
|
+
address?: Address;
|
|
142
214
|
displayName: string;
|
|
143
215
|
capabilities: AgentCapability[];
|
|
216
|
+
/** Uncompressed secp256k1 public key: 130 hex chars, leading `04`, NO 0x prefix. */
|
|
144
217
|
publicKey: string;
|
|
145
218
|
agentCardUrl?: string;
|
|
146
219
|
mcpEndpointUrl?: string;
|
|
147
220
|
minReward?: string;
|
|
148
221
|
preferredCapabilities?: AgentCapability[];
|
|
149
222
|
/** Settlement chains ('0g', 'base', …) this executor can sign
|
|
150
|
-
* `submitEvidence` on.
|
|
151
|
-
*
|
|
152
|
-
*
|
|
223
|
+
* `submitEvidence` on. Older backends store it on the executor record
|
|
224
|
+
* only; newer ones also leave the executor out of offers and refuse bids
|
|
225
|
+
* and /accept (409 CHAIN_UNSUPPORTED) for tasks on other chains — and for
|
|
226
|
+
* tasks indexed before chains were recorded unless it lists both '0g' and
|
|
227
|
+
* 'base'. No backend
|
|
228
|
+
* filters browse results by it, so the caller must check a task's chain
|
|
229
|
+
* (`entry.meta.chain`) before accepting — WorkerRuntime does. Backends
|
|
230
|
+
* that predate the field drop it. */
|
|
153
231
|
supportedChains?: string[];
|
|
154
232
|
}
|
|
155
|
-
/** Params for BlindMarket.createAgent() —
|
|
233
|
+
/** Params for BlindMarket.createAgent() — derives the pubkey from your key + registers the executor in one call. */
|
|
156
234
|
export interface CreateAgentParams {
|
|
235
|
+
/**
|
|
236
|
+
* Private key of the wallet that OWNS the API key. The backend registers the
|
|
237
|
+
* API key's owner as the executor (never an address from the request), wraps
|
|
238
|
+
* briefs to the public key registered here, and builds `submitEvidence` for
|
|
239
|
+
* the owner address — so this must be that wallet's key. Never sent to the
|
|
240
|
+
* backend; only its public half is. Defaults to
|
|
241
|
+
* `BlindMarketConfig.executor.privateKey`. With neither, a random wallet is
|
|
242
|
+
* generated (it can decrypt briefs but cannot sign `submitEvidence` for the
|
|
243
|
+
* owner's address).
|
|
244
|
+
*/
|
|
245
|
+
privateKey?: string;
|
|
157
246
|
/** Display name for the agent in the marketplace. */
|
|
158
247
|
displayName: string;
|
|
159
248
|
/** Capabilities this agent offers. Use AgentCap.DATA_PROCESSING etc. */
|
|
160
249
|
capabilities: AgentCapability[];
|
|
161
250
|
/** Which of the above the agent prefers (subset of capabilities). */
|
|
162
251
|
preferredCapabilities?: AgentCapability[];
|
|
163
|
-
/** Minimum reward per task (
|
|
252
|
+
/** Minimum reward per task, as an integer string in the payment token's smallest unit (USDC: 6 decimals). */
|
|
164
253
|
minReward?: string;
|
|
165
254
|
/** Agent card URL for marketplace display. */
|
|
166
255
|
agentCardUrl?: string;
|
|
@@ -172,9 +261,12 @@ export interface CreateAgentParams {
|
|
|
172
261
|
}
|
|
173
262
|
/** Result of BlindMarket.createAgent(). */
|
|
174
263
|
export interface CreateAgentResult {
|
|
264
|
+
/** The registered executor — `executor.address` is the API key's owner wallet. */
|
|
175
265
|
executor: ExecutorProfile;
|
|
266
|
+
/** The wallet of the `privateKey` you passed in, or the generated one. */
|
|
176
267
|
wallet: {
|
|
177
268
|
address: Address;
|
|
269
|
+
/** Uncompressed secp256k1 public key, 0x-prefixed (`0x04…`); registered without the 0x. */
|
|
178
270
|
publicKey: string;
|
|
179
271
|
privateKey: string;
|
|
180
272
|
};
|
package/dist/worker/Worker.d.ts
CHANGED
|
@@ -45,9 +45,11 @@ export declare class Worker {
|
|
|
45
45
|
decryptInstructions(input: DecryptInstructionsInput): Promise<Uint8Array>;
|
|
46
46
|
submitEvidence(input: SubmitEvidenceInput): Promise<SubmitEvidenceResult>;
|
|
47
47
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
48
|
+
* Reclaim escrow after the deadline if completeVerification was never called.
|
|
49
|
+
* BlindEscrow.claimTimeout is `onlyAgent`: only the POSTER can call it, and it
|
|
50
|
+
* refunds the poster the full escrowed amount — the worker is paid nothing on
|
|
51
|
+
* a timeout (the 90% worker / 10% platform split applies only to a passed
|
|
52
|
+
* verification). Called from a worker wallet this reverts.
|
|
51
53
|
*/
|
|
52
54
|
claimTimeout(taskId: TaskId): Promise<TxReceiptLike>;
|
|
53
55
|
}
|
package/dist/worker/Worker.js
CHANGED
|
@@ -41,9 +41,11 @@ export class Worker {
|
|
|
41
41
|
return { rootHash, txHash: receipt.hash, receipt };
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
44
|
+
* Reclaim escrow after the deadline if completeVerification was never called.
|
|
45
|
+
* BlindEscrow.claimTimeout is `onlyAgent`: only the POSTER can call it, and it
|
|
46
|
+
* refunds the poster the full escrowed amount — the worker is paid nothing on
|
|
47
|
+
* a timeout (the 90% worker / 10% platform split applies only to a passed
|
|
48
|
+
* verification). Called from a worker wallet this reverts.
|
|
47
49
|
*/
|
|
48
50
|
async claimTimeout(taskId) {
|
|
49
51
|
const receipt = await this.deps.escrow.claimTimeout(taskId);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blindmarket/sdk",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.4",
|
|
4
4
|
"description": "BlindMarket SDK — deploy agents, assign workers, verify evidence",
|
|
5
5
|
"author": "BlindMarket Team",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,7 +32,8 @@
|
|
|
32
32
|
],
|
|
33
33
|
"type": "module",
|
|
34
34
|
"files": [
|
|
35
|
-
"dist"
|
|
35
|
+
"dist",
|
|
36
|
+
"CHANGELOG.md"
|
|
36
37
|
],
|
|
37
38
|
"main": "./dist/index.js",
|
|
38
39
|
"types": "./dist/index.d.ts",
|
|
@@ -52,13 +53,17 @@
|
|
|
52
53
|
},
|
|
53
54
|
"scripts": {
|
|
54
55
|
"build": "tsc",
|
|
55
|
-
"
|
|
56
|
+
"prepublishOnly": "npm run build",
|
|
57
|
+
"dev": "tsc --watch",
|
|
58
|
+
"test": "vitest run"
|
|
56
59
|
},
|
|
57
60
|
"dependencies": {
|
|
58
|
-
"ethers": "6.
|
|
61
|
+
"ethers": "6.17.0"
|
|
59
62
|
},
|
|
60
63
|
"devDependencies": {
|
|
61
64
|
"@types/node": "^22.15.3",
|
|
62
|
-
"
|
|
65
|
+
"fast-check": "^4.10.1",
|
|
66
|
+
"typescript": "^5.7.3",
|
|
67
|
+
"vitest": "^4.1.11"
|
|
63
68
|
}
|
|
64
69
|
}
|