Skip to content

Commit bc1964b

Browse files
author
AgentSIM
committed
chore: sync from monorepo v0.10.0-sync-test
1 parent b04523b commit bc1964b

3 files changed

Lines changed: 35 additions & 1720 deletions

File tree

README.md

Lines changed: 31 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,29 @@
1-
<p align="center">
2-
<a href="https://agentsim.dev">
3-
<img src="https://agentsim.dev/logo.svg" alt="AgentSIM" width="80" />
4-
</a>
5-
</p>
1+
# @agentsim/sdk
62

7-
<h1 align="center">@agentsim/sdk</h1>
8-
9-
<p align="center">
10-
<strong>TypeScript SDK for AgentSIM — real SIM-backed phone numbers for AI agents</strong>
11-
</p>
12-
13-
<p align="center">
14-
<a href="https://www.npmjs.com/package/@agentsim/sdk"><img src="https://img.shields.io/npm/v/@agentsim/sdk?color=%2334D058&label=npm" alt="npm version"></a>
15-
<a href="https://www.npmjs.com/package/@agentsim/sdk"><img src="https://img.shields.io/node/v/@agentsim/sdk" alt="Node.js version"></a>
16-
<a href="https://github.com/agentsimdev/agentsim-typescript/blob/main/LICENSE"><img src="https://img.shields.io/github/license/agentsimdev/agentsim-typescript" alt="License"></a>
17-
</p>
18-
19-
<p align="center">
20-
<a href="https://docs.agentsim.dev">Docs</a> ·
21-
<a href="https://agentsim.dev/dashboard">Dashboard</a> ·
22-
<a href="https://github.com/agentsimdev/agentsim-examples">Examples</a> ·
23-
<a href="https://github.com/agentsimdev/agentsim-mcp">MCP Server</a>
24-
</p>
25-
26-
---
27-
28-
Provision real carrier-routed mobile numbers, receive inbound SMS, and get parsed OTP codes — all from your AI agent. Zero runtime dependencies. Works in Node.js 18+, Bun, Deno, and Edge runtimes.
3+
TypeScript/JavaScript SDK for AgentSIM — autonomous OTP relay for AI agents. Zero runtime dependencies. Works in Node.js 18+, Bun, Deno, and Edge runtimes.
294

305
## Install
316

327
```bash
338
npm install @agentsim/sdk
9+
# or: bun add @agentsim/sdk
3410
```
3511

36-
```bash
37-
bun add @agentsim/sdk
38-
```
39-
40-
## Quick Start
12+
## Quickstart
4113

4214
```typescript
4315
import { provision } from "@agentsim/sdk";
4416

45-
// TypeScript 5.2+ with AsyncDisposable (recommended)
17+
// Using AsyncDisposable (TypeScript 5.2+, recommended)
4618
await using num = await provision({ agentId: "checkout-bot", country: "US" });
47-
await enterPhoneNumber(num.number); // "+14155552671"
19+
await enterPhoneNumber(num.number); // "+14155552671"
4820
const otp = await num.waitForOtp({ timeout: 60 });
49-
await enterOtp(otp.otpCode); // "847291"
21+
await enterOtp(otp.otpCode); // "847291"
5022
// number auto-released via [Symbol.asyncDispose]
5123
```
5224

5325
```typescript
54-
// Manual release (Node 18, no `using` declaration)
26+
// Manual release (Node 18, no using declaration)
5527
const num = await provision({ agentId: "checkout-bot" });
5628
try {
5729
const otp = await num.waitForOtp();
@@ -60,20 +32,18 @@ try {
6032
}
6133
```
6234

63-
## Authentication
35+
## Auth
6436

65-
Set `AGENTSIM_API_KEY` in your environment, or pass it to the client:
37+
Set `AGENTSIM_API_KEY` in your environment, or pass `apiKey` to the client constructor:
6638

6739
```typescript
68-
import { AgentSimClient, provision } from "@agentsim/sdk";
69-
70-
const client = new AgentSimClient("asm_live_xxx");
71-
const num = await provision({ agentId: "my-bot" }, client);
40+
import { AgentSimClient } from "@agentsim/sdk";
41+
const client = new AgentSimClient({ apiKey: "asm_live_xxx" });
7242
```
7343

7444
Get your API key at [agentsim.dev/dashboard](https://agentsim.dev/dashboard).
7545

76-
## API Reference
46+
## API
7747

7848
### `provision(options)`
7949

@@ -82,70 +52,36 @@ Provisions a number and returns a `NumberSession`.
8252
| Option | Type | Default | Description |
8353
|--------|------|---------|-------------|
8454
| `agentId` | `string` | required | Identifier for your agent |
85-
| `country` | `string` | `"US"` | ISO 3166-1 alpha-2 country code |
55+
| `country` | `string` | `"US"` | ISO country code |
8656
| `ttlSeconds` | `number` | `3600` | Auto-release after N seconds |
87-
| `webhookUrl` | `string` || Receive OTPs via webhook |
57+
| `webhookUrl` | `string` || POST OTPs here as they arrive |
58+
| `apiKey` | `string` | env var | Override `AGENTSIM_API_KEY` |
8859

8960
### `num.waitForOtp(options?)`
9061

9162
Waits for an OTP to arrive on the provisioned number.
9263

93-
| Option | Type | Default | Description |
94-
|--------|------|---------| ------------|
95-
| `timeout` | `number` | `60` | Max seconds to wait |
96-
| `autoReroute` | `boolean` | `false` | Swap number on timeout |
97-
| `maxReroutes` | `number` | `2` | Max reroute attempts |
64+
| Option | Type | Default |
65+
|--------|------|---------|
66+
| `timeout` | `number` | `60` |
9867

9968
Returns `{ otpCode: string, fromNumber: string | null, receivedAt: string }`.
10069

101-
### `num.release()`
102-
103-
Release the number early. Called automatically by `[Symbol.asyncDispose]`.
70+
Throws `OtpTimeoutError` if no OTP arrives within `timeout` seconds.
10471

105-
### `num.getMessages()`
106-
107-
List all SMS messages received in this session.
108-
109-
## Error Handling
110-
111-
```typescript
112-
import { provision, OtpTimeoutError, PoolExhaustedError } from "@agentsim/sdk";
113-
114-
try {
115-
await using num = await provision({ agentId: "my-bot" });
116-
const otp = await num.waitForOtp({ timeout: 30 });
117-
} catch (err) {
118-
if (err instanceof OtpTimeoutError) {
119-
console.log("No OTP received — not billed");
120-
} else if (err instanceof PoolExhaustedError) {
121-
console.log("No numbers available");
122-
}
123-
}
124-
```
125-
126-
| Class | HTTP | When |
127-
|-------|------|------|
128-
| `AuthenticationError` | 401 | Missing or invalid API key |
129-
| `ForbiddenError` | 403 | Key revoked or lacking permissions |
130-
| `PoolExhaustedError` | 503 | No numbers available in requested country |
131-
| `OtpTimeoutError` | 408 | No OTP arrived within timeout (not billed) |
132-
| `RateLimitError` | 429 | Too many requests |
133-
| `SessionNotFoundError` | 404 | Session expired or already released |
134-
| `CountryNotAllowedError` | 403 | Country not on your plan |
135-
136-
## Pricing
72+
### `num.release()`
13773

138-
- **Hobby**: 10 free sessions/month
139-
- **Builder**: $0.99/session
140-
- Sessions that time out (`OtpTimeoutError`) are **not billed**
74+
Releases the number back to the pool early. Called automatically by `[Symbol.asyncDispose]`.
14175

142-
## Links
76+
## Error Reference
14377

144-
- [Documentation](https://docs.agentsim.dev)
145-
- [Python SDK](https://github.com/agentsimdev/agentsim-python)
146-
- [MCP Server](https://github.com/agentsimdev/agentsim-mcp)
147-
- [Examples](https://github.com/agentsimdev/agentsim-examples)
78+
| Class | When |
79+
|-------|------|
80+
| `AuthenticationError` | Missing or invalid API key |
81+
| `PoolExhaustedError` | No numbers available in requested country |
82+
| `OtpTimeoutError` | No OTP arrived within timeout |
83+
| `RateLimitError` | Too many requests |
14884

149-
## License
85+
## Supported Countries
15086

151-
[MIT](LICENSE)
87+
US (CA, AU, DE, FR coming soon)

0 commit comments

Comments
 (0)