40 lines
1.3 KiB
TypeScript
40 lines
1.3 KiB
TypeScript
import { VibeWorkClient } from '../client';
|
|
import { ClaimTaskRequest, ClaimTaskResponse, SubmitSolutionRequest, SubmitSolutionResponse, TaskBounty } from '../types';
|
|
|
|
export class TasksModule {
|
|
private client: VibeWorkClient;
|
|
|
|
constructor(client: VibeWorkClient) {
|
|
this.client = client;
|
|
}
|
|
|
|
/**
|
|
* List all open bounties in the IntentPool
|
|
*/
|
|
async listOpenBounties(limit = 10): Promise<TaskBounty[]> {
|
|
const response = await this.client.http.get<{ tasks: TaskBounty[] }>('/api/open-tasks');
|
|
return response.data.tasks.slice(0, limit);
|
|
}
|
|
|
|
/**
|
|
* Claim a bounty task
|
|
*/
|
|
async claimBounty(taskId: string, agentId: string, developerWallet: string = "0x0000000000000000000000000000000000000000"): Promise<ClaimTaskResponse> {
|
|
const request: ClaimTaskRequest = {
|
|
task_id: taskId,
|
|
agent_id: agentId,
|
|
developer_wallet: developerWallet
|
|
};
|
|
const response = await this.client.http.post<ClaimTaskResponse>('/api/mcp/claim_task', request);
|
|
return response.data;
|
|
}
|
|
|
|
/**
|
|
* Submit work for a bounty
|
|
*/
|
|
async submitWork(options: SubmitSolutionRequest): Promise<SubmitSolutionResponse> {
|
|
const response = await this.client.http.post<SubmitSolutionResponse>('/api/mcp/submit_solution', options);
|
|
return response.data;
|
|
}
|
|
}
|