From 0d4d6942016884ccb2f44633cb40207dde78d9bc Mon Sep 17 00:00:00 2001 From: OG T Date: Mon, 8 Jun 2026 13:43:54 +0800 Subject: [PATCH] feat: add @vibework/agent-sdk foundation --- packages/agent-sdk/package.json | 31 ++++++++++++++++ packages/agent-sdk/src/client.ts | 18 +++++++++ packages/agent-sdk/src/index.ts | 18 +++++++++ packages/agent-sdk/src/modules/identity.ts | 33 +++++++++++++++++ packages/agent-sdk/src/modules/tasks.ts | 43 ++++++++++++++++++++++ packages/agent-sdk/src/types.ts | 27 ++++++++++++++ packages/agent-sdk/tsconfig.json | 16 ++++++++ packages/agent-sdk/tsup.config.ts | 11 ++++++ pnpm-workspace.yaml | 5 ++- 9 files changed, 201 insertions(+), 1 deletion(-) create mode 100644 packages/agent-sdk/package.json create mode 100644 packages/agent-sdk/src/client.ts create mode 100644 packages/agent-sdk/src/index.ts create mode 100644 packages/agent-sdk/src/modules/identity.ts create mode 100644 packages/agent-sdk/src/modules/tasks.ts create mode 100644 packages/agent-sdk/src/types.ts create mode 100644 packages/agent-sdk/tsconfig.json create mode 100644 packages/agent-sdk/tsup.config.ts diff --git a/packages/agent-sdk/package.json b/packages/agent-sdk/package.json new file mode 100644 index 0000000..13135d3 --- /dev/null +++ b/packages/agent-sdk/package.json @@ -0,0 +1,31 @@ +{ + "name": "@vibework/agent-sdk", + "version": "1.0.0", + "description": "The official AI Agent-to-Agent SDK for VibeWork.", + "main": "dist/index.js", + "module": "dist/index.mjs", + "types": "dist/index.d.ts", + "exports": { + ".": { + "types": "./dist/index.d.ts", + "import": "./dist/index.mjs", + "require": "./dist/index.js" + } + }, + "scripts": { + "build": "tsup", + "dev": "tsup --watch" + }, + "keywords": [], + "author": "", + "license": "ISC", + "packageManager": "pnpm@10.32.1", + "devDependencies": { + "@types/node": "^20.19.42", + "tsup": "^8.5.1", + "typescript": "^5.9.3" + }, + "dependencies": { + "axios": "^1.17.0" + } +} diff --git a/packages/agent-sdk/src/client.ts b/packages/agent-sdk/src/client.ts new file mode 100644 index 0000000..c6549b9 --- /dev/null +++ b/packages/agent-sdk/src/client.ts @@ -0,0 +1,18 @@ +import axios, { AxiosInstance } from 'axios'; +import { AgentSdkOptions } from './types'; + +export class VibeWorkClient { + public http: AxiosInstance; + + constructor(options: AgentSdkOptions) { + const baseUrl = options.baseUrl || 'https://agent.wooo.work'; + + this.http = axios.create({ + baseURL: baseUrl, + headers: { + 'Content-Type': 'application/json', + ...(options.apiKey ? { 'Authorization': `Bearer ${options.apiKey}` } : {}) + } + }); + } +} diff --git a/packages/agent-sdk/src/index.ts b/packages/agent-sdk/src/index.ts new file mode 100644 index 0000000..cfe0034 --- /dev/null +++ b/packages/agent-sdk/src/index.ts @@ -0,0 +1,18 @@ +import { VibeWorkClient } from './client'; +import { AgentSdkOptions } from './types'; +import { TasksModule } from './modules/tasks'; +import { IdentityModule } from './modules/identity'; + +export * from './types'; + +export class VibeWorkAgentSDK { + public client: VibeWorkClient; + public tasks: TasksModule; + public identity: IdentityModule; + + constructor(options: AgentSdkOptions = {}) { + this.client = new VibeWorkClient(options); + this.tasks = new TasksModule(this.client); + this.identity = new IdentityModule(this.client); + } +} diff --git a/packages/agent-sdk/src/modules/identity.ts b/packages/agent-sdk/src/modules/identity.ts new file mode 100644 index 0000000..2ba07fa --- /dev/null +++ b/packages/agent-sdk/src/modules/identity.ts @@ -0,0 +1,33 @@ +import { VibeWorkClient } from '../client'; +import { AgentProfile } from '../types'; + +export class IdentityModule { + private client: VibeWorkClient; + + constructor(client: VibeWorkClient) { + this.client = client; + } + + /** + * Register or update an Agent Card + */ + async registerAgent(card: { + agent_id: string; + name: string; + description: string; + model_provider?: string; + capabilities: string[]; + x402_wallet_address?: string; + }): Promise { + const response = await this.client.http.post('/api/mcp/agent_card', card); + return response.data; + } + + /** + * Get an Agent Profile by ID + */ + async getProfile(agentId: string): Promise { + const response = await this.client.http.get(`/api/mcp/agent_card?agent_id=${agentId}`); + return response.data; + } +} diff --git a/packages/agent-sdk/src/modules/tasks.ts b/packages/agent-sdk/src/modules/tasks.ts new file mode 100644 index 0000000..05e9a60 --- /dev/null +++ b/packages/agent-sdk/src/modules/tasks.ts @@ -0,0 +1,43 @@ +import { VibeWorkClient } from '../client'; +import { TaskBounty, PagedResponse } from '../types'; + +export class TasksModule { + private client: VibeWorkClient; + + constructor(client: VibeWorkClient) { + this.client = client; + } + + /** + * List all open bounties in the IntentPool + */ + async listOpenBounties(): Promise> { + const response = await this.client.http.get('/api/open-tasks'); + return { + data: response.data, + total: response.data.length + }; + } + + /** + * Claim a bounty task + */ + async claimBounty(taskId: string, agentId: string): Promise { + const response = await this.client.http.post(`/api/mcp/claim_task`, { + taskId, + agentId + }); + return response.data; + } + + /** + * Submit work for a bounty + */ + async submitWork(taskId: string, pullRequestUrl: string): Promise { + const response = await this.client.http.post(`/api/mcp/submit_work`, { + taskId, + pullRequestUrl + }); + return response.data; + } +} diff --git a/packages/agent-sdk/src/types.ts b/packages/agent-sdk/src/types.ts new file mode 100644 index 0000000..7079212 --- /dev/null +++ b/packages/agent-sdk/src/types.ts @@ -0,0 +1,27 @@ +export interface AgentSdkOptions { + apiKey?: string; + baseUrl?: string; +} + +export interface PagedResponse { + data: T[]; + total: number; +} + +export interface TaskBounty { + id: string; + title: string; + description: string; + reward_amount: number; + reward_currency: string; + status: 'OPEN' | 'ASSIGNED' | 'IN_REVIEW' | 'COMPLETED' | 'CANCELLED'; + requirements: string[]; +} + +export interface AgentProfile { + id: string; + name: string; + capabilities: string[]; + wallet_address?: string; + reputation_score?: number; +} diff --git a/packages/agent-sdk/tsconfig.json b/packages/agent-sdk/tsconfig.json new file mode 100644 index 0000000..1d679f8 --- /dev/null +++ b/packages/agent-sdk/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "target": "ES2022", + "module": "NodeNext", + "moduleResolution": "NodeNext", + "strict": true, + "esModuleInterop": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true, + "declaration": true, + "declarationMap": true, + "outDir": "dist" + }, + "include": ["src/**/*"], + "exclude": ["node_modules", "dist"] +} diff --git a/packages/agent-sdk/tsup.config.ts b/packages/agent-sdk/tsup.config.ts new file mode 100644 index 0000000..69381c6 --- /dev/null +++ b/packages/agent-sdk/tsup.config.ts @@ -0,0 +1,11 @@ +import { defineConfig } from 'tsup'; + +export default defineConfig({ + entry: ['src/index.ts'], + format: ['cjs', 'esm'], + dts: true, + splitting: false, + sourcemap: true, + clean: true, + minify: true +}); diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 0e5a073..727683d 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -1,3 +1,6 @@ packages: - - "packages/*" - "apps/*" + - "packages/*" + - "packages/mcp-server" + - "packages/contracts" + - "packages/agent-sdk"