Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions packages/sdk-ts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# @superagentskill/sdk

Official TypeScript SDK for the [Super Agent Skill](https://superagentskill.com) MCP server.

```bash
npm install @superagentskill/sdk
```

## Usage

```ts
import { SuperAgentSkill, idempotencyKey } from "@superagentskill/sdk";

const sas = new SuperAgentSkill({
token: process.env.SAS_TOKEN, // optional for read tools, required for writes
});

// Strongly-typed tool calls
const out = await sas.call("search_registry", { query: "cardiology", limit: 5 });
// ^? { query: string; count: number; items: Package[] }

// Idempotent writes — retry-safe
await sas.call("upload_packages", {
files: [{ name: "triage.md", content: "# Cardiology triage" }],
idempotency_key: idempotencyKey(["triage", "v1"]),
});

// Rate-limit aware (parsed from X-RateLimit-* headers)
console.log(sas.lastRateLimit);
// → { limit: 100, remaining: 87, resetAtUnix: 1716508800, window: "day" }
```

## What's handled for you

- **Headers** — sets `Accept: application/json, text/event-stream` (the 406 footgun) automatically.
- **Auth** — Bearer header from `token`. On 401, throws `MCPUnauthorizedError` with the recovery URLs from the server hint.
- **Retries** — 3 attempts by default. 429s honour `Retry-After`; 5xx and network errors use exponential backoff.
- **Rate-limit visibility** — `sas.lastRateLimit` is populated after every call so you can self-regulate before hitting the ceiling.
- **Idempotency keys** — pass `idempotency_key` to write tools (`upload_packages`, `request_primitive`) and retries replay the original response instead of double-charging quota or duplicating drafts. The `idempotencyKey()` helper builds a stable key from any tuple.
- **Strongly typed** — every tool has typed input + output via `ToolMap`. Adding a new tool means updating one file.

## Tools

| Tool | Read | Auth |
|---------------------|:----:|:----:|
| `list_packages` | ✓ | |
| `search_registry` | ✓ | |
| `get_package` | ✓ | |
| `get_methodology` | ✓ | |
| `review_skill` | ✓ | |
| `report_execution` | ✓ | |
| `upload_packages` | ✗ | ✓ |
| `request_primitive` | ✗ | ✓ |

## Errors

```ts
import { MCPUnauthorizedError, MCPRateLimitedError } from "@superagentskill/sdk";

try {
await sas.call("upload_packages", { files: [...] });
} catch (e) {
if (e instanceof MCPUnauthorizedError) {
console.error("Authorize at", e.authorizationUrl);
} else if (e instanceof MCPRateLimitedError) {
console.warn("Retry after", e.retryAfterSeconds, "s");
} else throw e;
}
```

## Health check

```ts
const h = await sas.health();
// → { ok: true, version: "1.5.0", uptime_seconds: 41234, db: { ok: true, ping_ms: 12 }, ... }
```

## License

MIT
33 changes: 33 additions & 0 deletions packages/sdk-ts/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions packages/sdk-ts/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "@superagentskill/sdk",
"version": "0.1.0",
"description": "Official TypeScript SDK for the Super Agent Skill MCP server. Strongly-typed tool calls, automatic retries with exponential backoff, idempotency keys, rate-limit aware, Bearer-token auth.",
"type": "module",
"main": "./dist/index.js",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
}
},
"files": ["dist", "README.md"],
"scripts": {
"build": "tsc -p tsconfig.json",
"prepublishOnly": "npm run build"
},
"keywords": ["mcp", "claude", "agent", "skill", "ai", "superagentskill"],
"license": "MIT",
"engines": { "node": ">=18" },
"homepage": "https://superagentskill.com/docs/mcp",
"repository": {
"type": "git",
"url": "https://github.com/criptogus/agent-evolve-network",
"directory": "packages/sdk-ts"
},
"devDependencies": {
"typescript": "^5.6.0"
}
}
Loading
Loading