{"_id":"@agentdyne/sdk","name":"@agentdyne/sdk","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@agentdyne/sdk","version":"1.0.0","description":"Official JavaScript / TypeScript SDK for AgentDyne","author":{"name":"AgentDyne, Inc.","email":"sdk@agentdyne.com"},"license":"MIT","homepage":"https://agentdyne.com","repository":{"type":"git","url":"git+https://github.com/agentdyne/sdk-js.git"},"keywords":["agentdyne","ai","agents","llm","sdk","mcp","anthropic"],"type":"module","exports":{".":{"import":"./dist/index.js","require":"./dist/index.cjs","types":"./dist/index.d.ts"}},"main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","engines":{"node":">=18.0.0"},"scripts":{"build":"tsc --project tsconfig.build.json","typecheck":"tsc --noEmit","prepublishOnly":"npm run typecheck && npm run build"},"devDependencies":{"@types/node":"^20.0.0","typescript":"^5.4.0"},"_id":"@agentdyne/sdk@1.0.0","gitHead":"28ea31cbff08d5e663c55fa5e1f8138879a9174b","bugs":{"url":"https://github.com/agentdyne/sdk-js/issues"},"_nodeVersion":"20.19.6","_npmVersion":"10.8.2","dist":{"integrity":"sha512-irjVz2u91BLnfQejr3/XmkNlPNahDI4qR0qK747GByl+lNXnSDSOL6jqhq9wh6nrmFtXWgkb/OzXpFYjrLJxRQ==","shasum":"1bd80fe1cb1e92f332ed19373e8e12ae744d7fe8","tarball":"https://registry.npmjs.org/@agentdyne/sdk/-/sdk-1.0.0.tgz","fileCount":30,"unpackedSize":91616,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDYYroi5cy/boimgG7qmuskA1OSePWNjrKWDrcR83L/ggIgZGAJk1433mtEI1yyPBVx2zJwbXi29kyhSidLh+5C+yE="}]},"_npmUser":{"name":"inteleion-ai","email":"support@inteleion.com"},"directories":{},"maintainers":[{"name":"inteleion-ai","email":"support@inteleion.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sdk_1.0.0_1776082374704_0.7178395517905913"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-13T12:12:54.608Z","1.0.0":"2026-04-13T12:12:54.869Z","modified":"2026-04-13T12:12:55.059Z"},"maintainers":[{"name":"inteleion-ai","email":"support@inteleion.com"}],"description":"Official JavaScript / TypeScript SDK for AgentDyne","homepage":"https://agentdyne.com","keywords":["agentdyne","ai","agents","llm","sdk","mcp","anthropic"],"repository":{"type":"git","url":"git+https://github.com/agentdyne/sdk-js.git"},"author":{"name":"AgentDyne, Inc.","email":"sdk@agentdyne.com"},"bugs":{"url":"https://github.com/agentdyne/sdk-js/issues"},"license":"MIT","readme":"# @agentdyne/sdk\n\nOfficial JavaScript / TypeScript SDK for [AgentDyne](https://agentdyne.com) — The Global Microagent Marketplace.\n\n[![npm version](https://img.shields.io/npm/v/@agentdyne/sdk.svg)](https://www.npmjs.com/package/@agentdyne/sdk)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)\n[![TypeScript](https://img.shields.io/badge/TypeScript-5.4+-blue.svg)](https://www.typescriptlang.org/)\n\n## Installation\n\n```bash\nnpm install @agentdyne/sdk\n# or\nyarn add @agentdyne/sdk\n# or\npnpm add @agentdyne/sdk\n```\n\n## Quick Start\n\n```typescript\nimport AgentDyne from \"@agentdyne/sdk\";\n\nconst client = new AgentDyne({\n  apiKey: process.env.AGENTDYNE_API_KEY!,\n});\n\n// Execute an agent\nconst result = await client.execute(\"agent_id\", \"Summarize this email...\");\nconsole.log(result.output);\n// → { summary: \"...\", actionItems: [...], urgency: \"high\" }\n\n// Stream output token-by-token\nfor await (const chunk of client.stream(\"agent_id\", \"Explain quantum computing\")) {\n  if (chunk.type === \"delta\") process.stdout.write(chunk.delta ?? \"\");\n}\n```\n\n## Authentication\n\nCreate your API key at [agentdyne.com/api-keys](https://agentdyne.com/api-keys).\n\nSet it as an environment variable:\n\n```bash\nexport AGENTDYNE_API_KEY=agd_your_key_here\n```\n\nOr pass it directly:\n\n```typescript\nconst client = new AgentDyne({ apiKey: \"agd_your_key_here\" });\n```\n\n## Core Concepts\n\n### Agents\n\n```typescript\n// List agents with filters\nconst { data, pagination } = await client.agents.list({\n  category: \"coding\",\n  sort: \"rating\",\n  limit: 10,\n});\n\n// Get a single agent\nconst agent = await client.agents.get(\"agent_id\");\n\n// Search by keyword\nconst results = await client.agents.search(\"email summarizer\");\n\n// Iterate ALL agents automatically (async generator)\nfor await (const agent of client.agents.paginate({ category: \"finance\" })) {\n  console.log(agent.name, agent.average_rating);\n}\n\n// Featured agents\nconst featured = await client.agents.featured();\n```\n\n### Execute Agents\n\n```typescript\n// Synchronous (waits for completion)\nconst result = await client.agents.execute(\"agent_id\", {\n  input: { text: \"Quarterly revenue grew 40%...\" },\n});\nconsole.log(result.output, result.latencyMs, result.cost);\n\n// With idempotency key (safe to retry on network failure)\nconst result = await client.agents.execute(\"agent_id\", {\n  input: \"Hello\",\n  idempotencyKey: crypto.randomUUID(),\n});\n\n// Streaming (token-by-token)\nfor await (const chunk of client.agents.stream(\"agent_id\", { input: \"Hello\" })) {\n  switch (chunk.type) {\n    case \"delta\": process.stdout.write(chunk.delta ?? \"\"); break;\n    case \"done\":  console.log(\"\\nDone! executionId:\", chunk.executionId); break;\n    case \"error\": console.error(\"Stream error:\", chunk.error); break;\n  }\n}\n```\n\n### Executions\n\n```typescript\n// List execution history\nconst { data } = await client.executions.list({ status: \"failed\", limit: 20 });\n\n// Get a specific execution\nconst exec = await client.executions.get(\"exec_id\");\n\n// Poll until terminal state (success / failed / timeout)\nconst result = await client.executions.poll(\"exec_id\", {\n  intervalMs: 500,  // poll every 500ms\n  timeoutMs: 60000, // give up after 60s\n});\n```\n\n### User & Quota\n\n```typescript\nconst me = await client.user.me();\nconsole.log(me.subscription_plan); // \"pro\"\n\nconst quota = await client.user.quota();\nconsole.log(`${quota.used}/${quota.quota} calls used (${quota.percentUsed.toFixed(1)}%)`);\n\n// Update profile\nawait client.user.update({ full_name: \"Ada Lovelace\", bio: \"AI researcher\" });\n```\n\n### Reviews\n\n```typescript\n// List reviews for an agent\nconst { data: reviews } = await client.agents.reviews.list(\"agent_id\");\n\n// Post a review (requires prior execution)\nawait client.agents.reviews.create(\"agent_id\", {\n  rating: 5,\n  title:  \"Incredible accuracy\",\n  body:   \"Handles edge cases I didn't even consider.\",\n});\n```\n\n### Webhooks\n\n```typescript\n// In a Next.js App Router handler:\nexport async function POST(request: Request) {\n  const rawBody = await request.text();\n  const signature = request.headers.get(\"x-agentdyne-signature\") ?? \"\";\n\n  const client = new AgentDyne({ apiKey: process.env.AGENTDYNE_API_KEY! });\n  const event = await client.webhooks.constructEvent(\n    rawBody,\n    signature,\n    process.env.AGENTDYNE_WEBHOOK_SECRET!\n  );\n\n  switch (event.type) {\n    case \"execution.completed\":\n      console.log(\"Execution finished:\", event.data.executionId);\n      break;\n    case \"subscription.created\":\n      // Provision user access...\n      break;\n  }\n\n  return Response.json({ received: true });\n}\n```\n\n## Error Handling\n\nEvery error extends `AgentDyneError` — use `instanceof` checks for specific handling:\n\n```typescript\nimport {\n  AgentDyneError,\n  AuthenticationError,\n  QuotaExceededError,\n  RateLimitError,\n  NotFoundError,\n  SubscriptionRequiredError,\n} from \"@agentdyne/sdk\";\n\ntry {\n  await client.execute(\"agent_id\", \"Hello\");\n} catch (err) {\n  if (err instanceof QuotaExceededError) {\n    console.log(\"Upgrade plan at agentdyne.com/billing\");\n  } else if (err instanceof RateLimitError) {\n    await new Promise(r => setTimeout(r, err.retryAfterMs));\n  } else if (err instanceof SubscriptionRequiredError) {\n    console.log(\"Subscribe to use this agent\");\n  } else if (err instanceof NotFoundError) {\n    console.log(\"Agent not found\");\n  } else if (err instanceof AuthenticationError) {\n    console.log(\"Check your API key\");\n  } else if (err instanceof AgentDyneError) {\n    console.log(err.message, err.statusCode, err.code);\n  }\n}\n```\n\n## Configuration\n\n```typescript\nconst client = new AgentDyne({\n  apiKey:     \"agd_...\",          // Required\n  baseUrl:    \"http://localhost:3000\", // Override for local dev\n  maxRetries: 3,                  // Retries on 429/5xx (default: 3)\n  timeout:    60_000,             // Request timeout ms (default: 60000)\n  fetch:      customFetch,        // Custom fetch implementation\n});\n```\n\n## Framework Examples\n\n### Next.js App Router\n\n```typescript\n// app/api/summarize/route.ts\nimport AgentDyne from \"@agentdyne/sdk\";\n\nconst client = new AgentDyne({ apiKey: process.env.AGENTDYNE_API_KEY! });\n\nexport async function POST(req: Request) {\n  const { text } = await req.json();\n  const result = await client.execute(\"email-summarizer-pro\", { input: text });\n  return Response.json(result.output);\n}\n```\n\n### Edge Runtime (Cloudflare Workers)\n\n```typescript\nimport AgentDyne from \"@agentdyne/sdk\";\n\nexport default {\n  async fetch(request: Request, env: Env) {\n    const client = new AgentDyne({ apiKey: env.AGENTDYNE_API_KEY });\n    const result = await client.execute(\"agent_id\", \"Hello from the edge!\");\n    return new Response(JSON.stringify(result.output), {\n      headers: { \"Content-Type\": \"application/json\" },\n    });\n  },\n};\n```\n\n### Node.js Script\n\n```typescript\nimport AgentDyne from \"@agentdyne/sdk\";\n\nconst client = new AgentDyne({ apiKey: process.env.AGENTDYNE_API_KEY! });\n\nasync function main() {\n  // Stream a long-form response\n  process.stdout.write(\"Output: \");\n  for await (const chunk of client.stream(\"content-writer\", \"Write a blog post about AI agents\")) {\n    if (chunk.type === \"delta\") process.stdout.write(chunk.delta ?? \"\");\n  }\n  console.log(\"\\n✓ Done\");\n}\n\nmain().catch(console.error);\n```\n\n## Requirements\n\n- Node.js ≥ 18 (uses native `fetch` and `crypto.subtle`)\n- TypeScript ≥ 5.0 (optional but recommended)\n- Works in: Node.js, Deno, Bun, Cloudflare Workers, Vercel Edge, browsers\n\n## License\n\nMIT © 2026 AgentDyne, Inc.\n","readmeFilename":"README.md","_rev":"1-328d32c1a0bde03aa5ca51d0c1c19ca3"}