@oneshot-agent/sdk 0.55.0 → 0.57.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +136 -734
- package/dist/approvals.d.ts +1 -1
- package/dist/approvals.d.ts.map +1 -1
- package/dist/deadline.d.ts.map +1 -1
- package/dist/deadline.js +17 -4
- package/dist/deadline.js.map +1 -1
- package/dist/errors.d.ts +6 -2
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +37 -2
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +49 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +292 -124
- package/dist/index.js.map +1 -1
- package/dist/predict-input.generated.d.ts +59 -0
- package/dist/predict-input.generated.d.ts.map +1 -0
- package/dist/predict-input.generated.js +3 -0
- package/dist/predict-input.generated.js.map +1 -0
- package/dist/predict.d.ts +97 -0
- package/dist/predict.d.ts.map +1 -0
- package/dist/predict.js +3 -0
- package/dist/predict.js.map +1 -0
- package/dist/types.d.ts +53 -25
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,799 +1,201 @@
|
|
|
1
1
|
# @oneshot-agent/sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Your agent can think. This lets it act: send email, make calls, research,
|
|
4
|
+
buy, build sites. It pays per action, gets a signed receipt, and spends
|
|
5
|
+
nothing you did not allow.
|
|
4
6
|
|
|
5
|
-
##
|
|
7
|
+
## Install
|
|
6
8
|
|
|
7
9
|
```bash
|
|
8
10
|
npm install @oneshot-agent/sdk
|
|
9
11
|
```
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
No code? Use the MCP server in Claude, Cursor or Claude Code:
|
|
14
|
+
`npx -y @oneshot-agent/mcp-server` ([setup](https://docs.oneshotagent.com/sdk/mcp)).
|
|
15
|
+
Teach your coding agent the tools: `npx skills add oneshot-agent/agent-skills`
|
|
16
|
+
([skills](https://github.com/oneshot-agent/agent-skills)).
|
|
12
17
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
npx -y @oneshot-agent/mcp-server
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
See the [MCP Server documentation](https://docs.oneshotagent.com/sdk/mcp) for setup instructions.
|
|
20
|
-
|
|
21
|
-
### Teach your coding agent to use OneShot
|
|
22
|
-
|
|
23
|
-
Install the OneShot [Agent Skills](https://skills.sh) into Claude Code, Cursor, Codex, and
|
|
24
|
-
[70+ other agents](https://github.com/vercel-labs/skills#supported-agents) so they know how to
|
|
25
|
-
call the SDK and MCP tools:
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
# All OneShot skills
|
|
29
|
-
npx skills add oneshot-agent/agent-skills
|
|
30
|
-
|
|
31
|
-
# Or just what you need (e.g. setup + email)
|
|
32
|
-
npx skills add oneshot-agent/agent-skills --skill oneshot --skill oneshot-email
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
Skills available: `oneshot` (setup/auth), `oneshot-email`, `oneshot-messaging`,
|
|
36
|
-
`oneshot-research`, `oneshot-enrichment`, `oneshot-commerce`, `oneshot-browser`,
|
|
37
|
-
`oneshot-build`, `oneshot-compute`, `soul-markets`. Source:
|
|
38
|
-
[oneshot-agent/agent-skills](https://github.com/oneshot-agent/agent-skills).
|
|
39
|
-
|
|
40
|
-
## Quick Start
|
|
18
|
+
## Start
|
|
41
19
|
|
|
42
20
|
```typescript
|
|
43
21
|
import { OneShot } from '@oneshot-agent/sdk';
|
|
44
22
|
|
|
45
|
-
const agent = new OneShot({
|
|
46
|
-
privateKey: process.env.AGENT_PRIVATE_KEY!
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
// Send email
|
|
50
|
-
await agent.email({
|
|
51
|
-
to: 'user@example.com',
|
|
52
|
-
subject: 'Hello',
|
|
53
|
-
body: 'Hello World!'
|
|
54
|
-
});
|
|
23
|
+
const agent = new OneShot({ privateKey: process.env.AGENT_PRIVATE_KEY! });
|
|
55
24
|
|
|
56
|
-
|
|
57
|
-
const call = await agent.voice({
|
|
58
|
-
objective: 'Call the restaurant to make a reservation for 2 at 7pm',
|
|
59
|
-
target_number: '+14155551234'
|
|
60
|
-
});
|
|
61
|
-
console.log(call.transcript);
|
|
62
|
-
|
|
63
|
-
// Send SMS
|
|
64
|
-
await agent.sms({
|
|
65
|
-
message: 'Your order has shipped!',
|
|
66
|
-
to_number: '+14155551234'
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
// Build a website
|
|
70
|
-
const site = await agent.build({
|
|
71
|
-
type: 'saas',
|
|
72
|
-
product: {
|
|
73
|
-
name: 'TaskFlow',
|
|
74
|
-
description: 'AI-powered task management for remote teams'
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
console.log('Live at:', site.production_url);
|
|
78
|
-
|
|
79
|
-
// Research
|
|
25
|
+
await agent.email({ to: 'user@example.com', subject: 'Hello', body: 'Hello world.' });
|
|
80
26
|
const report = await agent.research({ topic: 'AI agents', depth: 'deep' });
|
|
81
|
-
|
|
82
|
-
// Check balance
|
|
83
|
-
const balance = await agent.getBalance(agent.usdcAddress);
|
|
27
|
+
const usdc = await agent.getBalance(agent.usdcAddress);
|
|
84
28
|
```
|
|
85
29
|
|
|
86
|
-
|
|
30
|
+
Paid calls quote, pay and wait for the result. You write one line.
|
|
87
31
|
|
|
88
|
-
|
|
32
|
+
## What it does
|
|
89
33
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
`swapBufferMultiplier` × the charge (default 10, range 1–1000), so one swap
|
|
104
|
-
covers many calls. If your provider exposes `getBalance` and the wallet's ETH
|
|
105
|
-
cannot cover the buffer, it swaps just the shortfall (a send-only provider
|
|
106
|
-
always gets the buffered amount). Set `swapBufferMultiplier: 1` for
|
|
107
|
-
exact-shortfall swaps.
|
|
108
|
-
- Concurrent calls from one instance are serialized around the swap, so a burst
|
|
109
|
-
never double-swaps or races the wallet nonce.
|
|
110
|
-
|
|
111
|
-
Run one process per wallet in ETH mode: each process keeps its own in-flight
|
|
112
|
-
ledger. ETH mode requires a wallet provider with `sendTransaction` and is Base
|
|
113
|
-
mainnet only. CDP wallets are not supported in ETH mode: `cdp` combined with
|
|
114
|
-
`currency: 'ETH'` throws a `ValidationError` (fund the CDP wallet with USDC).
|
|
115
|
-
|
|
116
|
-
## Available Methods
|
|
117
|
-
|
|
118
|
-
| Method | Description |
|
|
119
|
-
|--------|-------------|
|
|
120
|
-
| **Communication** | |
|
|
121
|
-
| `email()` | Send emails with attachments |
|
|
122
|
-
| `voice()` | Make phone calls |
|
|
123
|
-
| `sms()` | Send SMS messages |
|
|
124
|
-
| `inboxList()` | List inbound emails |
|
|
125
|
-
| `inboxGet()` | Get email by ID |
|
|
126
|
-
| `smsInboxList()` | List inbound SMS |
|
|
127
|
-
| `smsInboxGet()` | Get SMS by ID |
|
|
128
|
-
| `notifications()` | List agent notifications |
|
|
129
|
-
| `markNotificationRead()` | Mark notification as read |
|
|
130
|
-
| **Domain Pool** | |
|
|
131
|
-
| `listDomains()` | List your sending domains with warmup/rotation state |
|
|
132
|
-
| `pauseDomain()` | Take a domain out of rotation |
|
|
133
|
-
| `resumeDomain()` | Put a paused domain back into rotation |
|
|
134
|
-
| **Research & People** | |
|
|
135
|
-
| `research()` | Deep web research |
|
|
136
|
-
| `solve(input)` | Solve a routing or packing problem with constraint checks and conflicts; `solution` is typed by `problem` |
|
|
137
|
-
| `personFind()` | Search people by criteria |
|
|
138
|
-
| `personProfile()` | Enrich from LinkedIn/email |
|
|
139
|
-
| `personEmail()` | Find email for a person |
|
|
140
|
-
| `personEmailStatus()` | Verify email deliverability |
|
|
141
|
-
| `companyFind()` | Search companies by name, domain, industry, location, size, funding |
|
|
142
|
-
| `companyProfile()` | Enrich a company from domain, name, LinkedIn URL, or ticker |
|
|
143
|
-
| `businessFind()` | Discover local businesses (restaurants, contractors, practices) by category × location |
|
|
144
|
-
| `businessResolve()` | Business name + address → website domain, phone, status, confidence |
|
|
145
|
-
| `recordSolicitationsFind()` | Federal Sources Sought / Presolicitation notices by NAICS with the contracting officer's contact |
|
|
146
|
-
| `personDossier()` | Person profile, known social accounts, articles, posts and written summary |
|
|
147
|
-
| `personSocialAccounts()` | Find all social accounts |
|
|
148
|
-
| `personArticles()` | Find articles about a person |
|
|
149
|
-
| `personPosts()` | Recent social posts with engagement |
|
|
150
|
-
| `personInterests()` | Analyze interests across categories |
|
|
151
|
-
| `personFollowers()` | Map followers, following, replies |
|
|
152
|
-
| **Web & Commerce** | |
|
|
153
|
-
| `webSearch()` | Search the web |
|
|
154
|
-
| `webRead()` | Read any URL as markdown + screenshot |
|
|
155
|
-
| `commerceBuy()` | Purchase products |
|
|
156
|
-
| `productFind()` | Search products |
|
|
157
|
-
| **Browser** | |
|
|
158
|
-
| `browser()` | Autonomous browser — navigate, click, extract |
|
|
159
|
-
| `createBrowserProfile()` | Create a persistent browser profile |
|
|
160
|
-
| `startBrowserProfileSetup(id, loginUrl)` | Start interactive account login / 2FA; returns the single-use `setup_url` |
|
|
161
|
-
| `createBrowserProfileSetupLink(id, startUrl?)` | Mint a fresh single-use `setup_url` for an open setup |
|
|
162
|
-
| `getBrowserProfileSetup(id)` | Get setup status; `completed_at` once the person pressed Done |
|
|
163
|
-
| `finishBrowserProfileSetup(id)` | Save profile and inspect stored cookie metadata |
|
|
164
|
-
| `listBrowserProfiles()` | List saved browser profiles |
|
|
165
|
-
| `deleteBrowserProfile()` | Delete a browser profile |
|
|
166
|
-
| **Build** | |
|
|
167
|
-
| `build()` | Build and deploy production websites |
|
|
168
|
-
| `updateBuild()` | Update an existing website |
|
|
169
|
-
| **Compute (Agentic Goals)** | |
|
|
170
|
-
| `compute()` | Launch autonomous multi-step goal |
|
|
171
|
-
| `getComputeGoal()` | Get goal status and progress |
|
|
172
|
-
| `getComputeTasks()` | List tasks for a goal |
|
|
173
|
-
| `getComputeOutputs()` / `getComputeOutput()` | List what a goal's tasks produced, and read one output by key |
|
|
174
|
-
| `getComputeBudget()` | Check remaining budget for a goal |
|
|
175
|
-
| `respondToComputeTask()` | Provide input to a pending task |
|
|
176
|
-
| `pauseComputeGoal()` | Pause a running goal |
|
|
177
|
-
| `resumeComputeGoal()` | Resume a paused goal |
|
|
178
|
-
| `cancelComputeGoal()` | Cancel a goal |
|
|
179
|
-
| `fundComputeGoal()` | Add funds to a goal's budget |
|
|
180
|
-
| **Analytics & Balance** | |
|
|
181
|
-
| `getBalance()` | Check token balance |
|
|
182
|
-
| `getUnifiedBalance()` | Get balance across all chains |
|
|
183
|
-
| `spendBreakdown()` | Spending breakdown by tool/period |
|
|
184
|
-
| `rocs()` | Return on compute stats |
|
|
185
|
-
| `receiptsList()` | List payment receipts (`limit`/`offset` or `since`/`until` window) |
|
|
186
|
-
| `tagReceiptValue()` | Tag a receipt with business value (by `receipt_id` or `request_id`) |
|
|
187
|
-
| **Any route** | |
|
|
188
|
-
| `route(method, path, { params, query, body, paid })` | Call a declared route by method and path, with `{name}` path parameters, a query and a JSON body (an object field is sent as it is). A free route is signed like the other free calls (read proof for `GET`, write proof otherwise; the bearer token in an access-token session). `paid: true` (POST) goes through the quote-to-pay flow of `tool()`. The generated MCP route tools use it |
|
|
189
|
-
|
|
190
|
-
## Configuration
|
|
34
|
+
| Area | Methods |
|
|
35
|
+
|------|---------|
|
|
36
|
+
| [Talk](https://docs.oneshotagent.com/api-reference/email/send) | `email` `voice` `sms` `inboxList` `inboxGet` `smsInboxList` `smsInboxGet` `notifications` `markNotificationRead` |
|
|
37
|
+
| [Send from your domains](https://docs.oneshotagent.com/api-reference/email/domains) | `listDomains` `pauseDomain` `resumeDomain` |
|
|
38
|
+
| [Find people and companies](https://docs.oneshotagent.com/api-reference/research/person-find) | `personFind` `personProfile` `personEmail` `personEmailStatus` `personDossier` `personSocialAccounts` `personArticles` `personPosts` `personInterests` `personFollowers` `companyFind` `companyProfile` `businessFind` `businessResolve` `recordSolicitationsFind` |
|
|
39
|
+
| [Think](https://docs.oneshotagent.com/api-reference/research) | `research` `predict` `solve` |
|
|
40
|
+
| [Web and buying](https://docs.oneshotagent.com/api-reference/web-search) | `webSearch` `webRead` `productFind` `commerceBuy` `physicalMail` |
|
|
41
|
+
| [Browser](https://docs.oneshotagent.com/api-reference/browser/create) | `browser` `createBrowserProfile` `startBrowserProfileSetup` `createBrowserProfileSetupLink` `getBrowserProfileSetup` `finishBrowserProfileSetup` `listBrowserProfiles` `deleteBrowserProfile` |
|
|
42
|
+
| [LinkedIn](https://docs.oneshotagent.com/api-reference/linkedin/overview) | `linkedinConnect` `linkedinInvite` `linkedinWithdrawInvitation` `linkedinMessage` `linkedinReply` `reconnectLinkedInAccount` and more |
|
|
43
|
+
| [Build](https://docs.oneshotagent.com/api-reference/build/create) | `build` `updateBuild` |
|
|
44
|
+
| [Goals](https://docs.oneshotagent.com/api-reference/compute/create) | `compute` `waitForComputeGoal` `getComputeGoal` `getComputeTasks` `getComputeOutputs` `respondToComputeTask` `pauseComputeGoal` `resumeComputeGoal` `cancelComputeGoal` `fundComputeGoal` |
|
|
45
|
+
| [Money and receipts](https://docs.oneshotagent.com/api-reference/analytics/overview) | `getBalance` `getUnifiedBalance` `budgets` `topUpCredits` `spendBreakdown` `rocs` `receiptsList` `tagReceiptValue` |
|
|
46
|
+
| Anything else | `tool(name, input)` for any tool, `route(method, path, { params, query, body, paid })` for any declared route |
|
|
191
47
|
|
|
192
|
-
|
|
193
|
-
interface OneShotConfig {
|
|
194
|
-
privateKey?: string; // Option A: raw key
|
|
195
|
-
cdp?: boolean; // Option B: Coinbase CDP server wallet
|
|
196
|
-
walletProvider?: WalletProvider; // Option C: bring your own signer
|
|
197
|
-
accessToken?: string; // Option D: credits-only session, no key (see Access tokens)
|
|
198
|
-
address?: string; // With accessToken in the sync constructor; create() resolves it
|
|
199
|
-
defaultHeaders?: Record<string, string>; // Sent on every request
|
|
200
|
-
baseUrl?: string; // Override API URL
|
|
201
|
-
rpcUrl?: string; // Override RPC URL
|
|
202
|
-
debug?: boolean; // Enable logging
|
|
203
|
-
logger?: (msg: string) => void;
|
|
204
|
-
budgets?: { // Spend budget (see below)
|
|
205
|
-
daily?: number;
|
|
206
|
-
perTransaction?: number;
|
|
207
|
-
alertAt?: number;
|
|
208
|
-
pauseAt?: number;
|
|
209
|
-
};
|
|
210
|
-
alerts?: { email?: string };
|
|
211
|
-
}
|
|
212
|
-
```
|
|
48
|
+
## Money
|
|
213
49
|
|
|
214
|
-
|
|
50
|
+
- It pays in USDC on Base mainnet (`agent.chainId` is `8453`). Fund the wallet first.
|
|
51
|
+
- A call costs what the quote says, or it does not run.
|
|
52
|
+
- `maxCost` sets your ceiling. Above it, the SDK refuses to sign.
|
|
53
|
+
- `currency: 'ETH'` pays from ETH. The SDK swaps into USDC only when the wallet
|
|
54
|
+
is short, buys `swapBufferMultiplier` × the charge (default 10) so one swap
|
|
55
|
+
covers many calls. Calls in one process never double-swap. Run one process
|
|
56
|
+
per wallet. Not with `cdp`.
|
|
215
57
|
|
|
216
|
-
|
|
58
|
+
**Budgets** cap what a runaway loop can spend.
|
|
217
59
|
|
|
218
60
|
```typescript
|
|
219
61
|
const agent = await OneShot.create({
|
|
220
62
|
cdp: true,
|
|
221
|
-
budgets: {
|
|
222
|
-
daily: 50, // max USDC per UTC day
|
|
223
|
-
perTransaction: 5, // max USDC for any single call
|
|
224
|
-
alertAt: 0.8, // warn at 80% of daily
|
|
225
|
-
pauseAt: 1.0, // stop paying at 100%
|
|
226
|
-
},
|
|
63
|
+
budgets: { daily: 50, perTransaction: 5, alertAt: 0.8, pauseAt: 1.0 },
|
|
227
64
|
alerts: { email: 'you@example.com' },
|
|
228
65
|
});
|
|
229
66
|
```
|
|
230
67
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
At `alertAt` you get a notification (in-app via `agent.notifications()`, plus email
|
|
237
|
-
if you set one). At `pauseAt` paid calls are rejected with a `BudgetExceededError`
|
|
238
|
-
until the window resets at the next UTC midnight:
|
|
239
|
-
|
|
240
|
-
```typescript
|
|
241
|
-
try {
|
|
242
|
-
await agent.research({ topic: '...' });
|
|
243
|
-
} catch (err) {
|
|
244
|
-
if (err instanceof BudgetExceededError) {
|
|
245
|
-
console.log(`${err.reason} budget hit — $${err.spent} spent, resumes ${err.resetsAt}`);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
```
|
|
249
|
-
|
|
250
|
-
Check utilization any time:
|
|
251
|
-
|
|
252
|
-
```typescript
|
|
253
|
-
const b = await agent.budgets();
|
|
254
|
-
// { daily_usdc: 50, spent_today_usdc: '41.20', pct_used: 0.824, resets_at: '...' }
|
|
255
|
-
```
|
|
256
|
-
|
|
257
|
-
Omit `budgets` entirely to leave whatever is stored server-side untouched — agents
|
|
258
|
-
without a budget are unlimited, which is the default.
|
|
259
|
-
|
|
260
|
-
The sync **fails closed**: if the budget can't be confirmed with the server (network
|
|
261
|
-
error, 5xx, rate limit, rejected config) the paid call throws `BudgetSyncError` and is
|
|
262
|
-
not made — proceeding would silently drop the guardrail you asked for. It retries on
|
|
263
|
-
the next paid call. An invalid config (`daily: -1`, `alertAt: 2`) throws `ValidationError`
|
|
264
|
-
at construction.
|
|
265
|
-
|
|
266
|
-
## Authentication
|
|
267
|
-
|
|
268
|
-
Every request identifies you by your wallet address (`X-Agent-ID`). Paid tools additionally settle a signed [x402](https://x402.org) USDC payment.
|
|
269
|
-
|
|
270
|
-
**Read endpoints** — `inboxList` / `inboxGet`, `smsInboxList` / `smsInboxGet`, `notifications` / `markNotificationRead`, `getUnifiedBalance`, and `createBrowserProfile` / `listBrowserProfiles` / `deleteBrowserProfile` — return private, per-agent data. Since a wallet address is public, the SDK proves you actually control it: on each read it signs a short-lived **EIP-712 read proof** and sends it as the `x-agent-proof` header. The API verifies the signature locally and rejects any request whose proof doesn't match the `X-Agent-ID` wallet, so no one can read your inbox/balance by supplying your address.
|
|
271
|
-
|
|
272
|
-
This is fully automatic — you don't do anything beyond providing your `privateKey`. **Requires SDK ≥ 0.25.0.** Older SDKs (or raw HTTP callers) will keep working until the API enables enforcement, after which they must send a valid `x-agent-proof`; upgrade to stay ahead of it.
|
|
273
|
-
|
|
274
|
-
### Access tokens (credits-only sessions)
|
|
275
|
-
|
|
276
|
-
Some code can't hold your wallet key — a hosted MCP client such as Grok Bot, a cloud
|
|
277
|
-
runner, a third-party agent platform. For those, mint an **access token** from a wallet
|
|
278
|
-
session and hand it over instead:
|
|
279
|
-
|
|
280
|
-
```typescript
|
|
281
|
-
// From a wallet session (once):
|
|
282
|
-
const { token } = await agent.createAccessToken({ name: 'grok-bot' });
|
|
283
|
-
|
|
284
|
-
// In the hosted environment:
|
|
285
|
-
const hosted = await OneShot.create({ accessToken: token }); // resolves the wallet address
|
|
286
|
-
await hosted.webSearch({ query: '…' }); // billed to the agent's credits
|
|
287
|
-
```
|
|
288
|
-
|
|
289
|
-
An access-token session identifies the agent with the token (no `x-agent-proof`), **pays
|
|
290
|
-
every call from the agent's prepaid credit balance**, and never signs x402. When credits
|
|
291
|
-
can't cover a call it throws `InsufficientCreditsError` (`required`, `balance`,
|
|
292
|
-
`shortfall`) — top up from the wallet session with `agent.topUpCredits(amount)` (pays
|
|
293
|
-
the same USDC via x402) and retry. Budgets set on the agent still apply, with credit-funded
|
|
294
|
-
spend counted; they are **read-only** from a token session (`agent.budgets()` works,
|
|
295
|
-
passing `budgets` to the constructor throws). A token cannot mint, list, or revoke
|
|
296
|
-
tokens; do that from the wallet session (`listAccessTokens()`, `revokeAccessToken(id)`).
|
|
297
|
-
`accessToken` is exclusive with `privateKey` / `cdp` / `walletProvider` and with
|
|
298
|
-
`currency: 'ETH'`. **Requires SDK ≥ 0.33.0.**
|
|
299
|
-
|
|
300
|
-
## Tool Options
|
|
68
|
+
- Budgets live on the server. Every process using the wallet shares them.
|
|
69
|
+
- If the server cannot confirm them, nothing is paid: `BudgetSyncError`.
|
|
70
|
+
- At `pauseAt`, paid calls throw `BudgetExceededError` until UTC midnight.
|
|
71
|
+
- Omit `budgets` and the stored ones stay as they are. No budget means no limit.
|
|
301
72
|
|
|
302
|
-
|
|
73
|
+
**Access tokens** are for code that must not hold the key: a hosted MCP client,
|
|
74
|
+
a cloud runner, someone else's platform.
|
|
303
75
|
|
|
304
76
|
```typescript
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
signal?: AbortSignal; // Cancel before payment (see Cancellation section)
|
|
309
|
-
wait?: boolean; // Wait for async jobs (default: true)
|
|
310
|
-
onStatusUpdate?: (status: string, requestId: string) => void;
|
|
311
|
-
}
|
|
77
|
+
const { token } = await agent.createAccessToken({ name: 'grok-bot' }); // from the wallet session
|
|
78
|
+
const hosted = await OneShot.create({ accessToken: token });
|
|
79
|
+
await hosted.webSearch({ query: '…' }); // paid from credits
|
|
312
80
|
```
|
|
313
81
|
|
|
314
|
-
|
|
82
|
+
- A token spends prepaid credits only. It never signs a payment.
|
|
83
|
+
- Short of credits, it throws `InsufficientCreditsError` (`required`, `balance`,
|
|
84
|
+
`shortfall`). Top up from the wallet session with `topUpCredits(amount)`.
|
|
85
|
+
- A token reads budgets but cannot change them, and cannot mint or revoke tokens.
|
|
315
86
|
|
|
316
|
-
|
|
87
|
+
## Trust
|
|
317
88
|
|
|
318
|
-
|
|
319
|
-
|--------|:---------:|
|
|
320
|
-
| `commerceBuy()` | Supported |
|
|
321
|
-
| `voice()` | Supported |
|
|
322
|
-
| `sms()` | Supported |
|
|
323
|
-
| `build()` / `updateBuild()` | Supported |
|
|
324
|
-
| `browser()` | Supported |
|
|
325
|
-
| All other tools | Not applicable (fixed low-cost pricing) |
|
|
326
|
-
|
|
327
|
-
## Verifying Receipts
|
|
328
|
-
|
|
329
|
-
Signed receipts use Ed25519 over the canonical public receipt fields, the `revision` counter and a SHA-256 digest of `metadata` — nothing private. The response also carries the `signature`, `digest`, `key_id` and `alg` needed to verify; those are not part of the signed bytes, and neither is the caller-supplied `value_tag`. Unsigned receipts return `malformed_receipt`. `verifyReceipt` works offline after fetching the public keys:
|
|
89
|
+
Every paid call returns a receipt, signed with Ed25519. Check it offline:
|
|
330
90
|
|
|
331
91
|
```typescript
|
|
332
92
|
import { verifyReceipt, receiptFromWire } from '@oneshot-agent/sdk/receipt';
|
|
333
93
|
|
|
334
|
-
// `wireReceipt` is whatever GET /v1/analytics/receipts (or the audit export)
|
|
335
|
-
// returned for one receipt — snake_case field names.
|
|
336
|
-
const receipt = receiptFromWire(wireReceipt);
|
|
337
94
|
const jwks = await fetch('https://win.oneshotagent.com/.well-known/oneshot-receipts.json').then(r => r.json());
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
if (result.valid) {
|
|
341
|
-
console.log(`Verified against key ${result.keyId}`);
|
|
342
|
-
} else {
|
|
343
|
-
// reason is one of: 'malformed_receipt' | 'key_not_found' | 'digest_mismatch' | 'signature_invalid'
|
|
344
|
-
console.log(`Verification failed (${result.reason}): ${result.message}`);
|
|
345
|
-
}
|
|
95
|
+
const result = verifyReceipt(receiptFromWire(wireReceipt), jwks);
|
|
96
|
+
// result.valid, or result.reason: 'malformed_receipt' | 'key_not_found' | 'digest_mismatch' | 'signature_invalid'
|
|
346
97
|
```
|
|
347
98
|
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
There is one canonical payload and no version field. `revision` starts at 1 and increments on every re-sign under the same row lock that protects the signature, so two signed copies of the same receipt order from the signed bytes alone. `metadata_digest` is a key-order-independent SHA-256 of the receipt's `metadata` (`memo`, `decisionContext`, …), stable for `metadata: null`; the metadata value itself is never placed in the signed bytes, so altering it after signing invalidates the signature without embedding unbounded agent-supplied data in the canonical payload. If the format ever changes, OneShot re-signs every stored receipt rather than versioning the payload — see `docs/architecture/receipt-signatures.md`.
|
|
351
|
-
|
|
352
|
-
### CLI
|
|
353
|
-
|
|
354
|
-
```bash
|
|
355
|
-
npx @oneshot-agent/sdk receipt.json
|
|
356
|
-
# or, after installing the package:
|
|
357
|
-
oneshot-verify-receipt receipt.json [jwksUrlOrPath]
|
|
358
|
-
```
|
|
99
|
+
Or from a shell: `npx @oneshot-agent/sdk receipt.json` (exit `0` valid, `1` invalid, `2` bad input).
|
|
100
|
+
Old keys stay in the key set, so old receipts keep verifying.
|
|
359
101
|
|
|
360
|
-
|
|
102
|
+
Reads of private data (inbox, notifications, balances, browser profiles) carry a
|
|
103
|
+
signed proof that you hold the wallet. A wallet address is public; your inbox is not.
|
|
104
|
+
The SDK signs it for you. If the server says your clock is off, it corrects once and retries.
|
|
361
105
|
|
|
362
|
-
##
|
|
106
|
+
## Failure
|
|
363
107
|
|
|
364
108
|
```typescript
|
|
365
|
-
import {
|
|
366
|
-
ValidationError,
|
|
367
|
-
ToolError,
|
|
368
|
-
JobError,
|
|
369
|
-
JobTimeoutError,
|
|
370
|
-
ContentBlockedError,
|
|
371
|
-
EmergencyNumberError
|
|
372
|
-
} from '@oneshot-agent/sdk';
|
|
109
|
+
import { JobError, JobTimeoutError, ToolError, ValidationError, ContentBlockedError } from '@oneshot-agent/sdk';
|
|
373
110
|
|
|
374
111
|
try {
|
|
375
|
-
await agent.voice({
|
|
376
|
-
objective: 'Make a call',
|
|
377
|
-
target_number: '+14155551234'
|
|
378
|
-
});
|
|
112
|
+
await agent.voice({ objective: 'Book a table for 2 at 7pm', target_number: '+14155551234' });
|
|
379
113
|
} catch (error) {
|
|
380
|
-
if (error instanceof
|
|
381
|
-
//
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
} else if (error instanceof
|
|
385
|
-
//
|
|
386
|
-
console.log(`Emergency number blocked: ${error.blockedNumber}`);
|
|
387
|
-
} else if (error instanceof ValidationError) {
|
|
388
|
-
console.log(`Invalid: ${error.field}`);
|
|
389
|
-
} else if (error instanceof ToolError) {
|
|
390
|
-
console.log(`API error: ${error.statusCode}`);
|
|
391
|
-
} else if (error instanceof JobTimeoutError) {
|
|
392
|
-
console.log(`Timeout: ${error.jobId}`);
|
|
393
|
-
} else if (error instanceof JobError) {
|
|
394
|
-
// An async job failed. `error.code` is a STABLE, machine-readable code —
|
|
395
|
-
// branch on it rather than parsing `error.message`.
|
|
396
|
-
switch (error.code) {
|
|
397
|
-
case 'insufficient_funds':
|
|
398
|
-
console.log('Fund your wallet — do not blind-retry');
|
|
399
|
-
break;
|
|
400
|
-
case 'invalid_input':
|
|
401
|
-
console.log('Fix the request — retrying as-is will not help');
|
|
402
|
-
break;
|
|
403
|
-
case 'rate_limited':
|
|
404
|
-
case 'service_unavailable':
|
|
405
|
-
case 'internal_error':
|
|
406
|
-
console.log('Transient — safe to retry');
|
|
407
|
-
break;
|
|
408
|
-
default:
|
|
409
|
-
console.log(`Job failed (${error.code}): ${error.message}`);
|
|
410
|
-
}
|
|
114
|
+
if (error instanceof JobError) {
|
|
115
|
+
// Branch on error.code, never on the message.
|
|
116
|
+
if (['rate_limited', 'service_unavailable', 'internal_error'].includes(error.code)) { /* retry */ }
|
|
117
|
+
else { /* fix the input or the funding; retrying as is will not help */ }
|
|
118
|
+
} else if (error instanceof ToolError && error.statusCode === 429) {
|
|
119
|
+
// error.retryAfterMs is the server's hint. The SDK never retries for you.
|
|
411
120
|
}
|
|
121
|
+
throw error;
|
|
412
122
|
}
|
|
413
123
|
```
|
|
414
124
|
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
`
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
const conference = await agent.voice({
|
|
480
|
-
objective: 'Connect the buyer and seller to negotiate the final price',
|
|
481
|
-
target_number: ['+14155551234', '+14155555678'],
|
|
482
|
-
caller_persona: 'A professional meeting facilitator'
|
|
483
|
-
});
|
|
484
|
-
```
|
|
485
|
-
|
|
486
|
-
### SMS
|
|
487
|
-
|
|
488
|
-
```typescript
|
|
489
|
-
// Single recipient
|
|
490
|
-
await agent.sms({
|
|
491
|
-
message: 'Your appointment is confirmed for tomorrow at 10am',
|
|
492
|
-
to_number: '+14155551234'
|
|
493
|
-
});
|
|
494
|
-
|
|
495
|
-
// Multiple recipients (up to 10)
|
|
496
|
-
await agent.sms({
|
|
497
|
-
message: 'Team meeting moved to 3pm',
|
|
498
|
-
to_number: ['+14155551234', '+14155555678', '+14155559012']
|
|
499
|
-
});
|
|
500
|
-
|
|
501
|
-
// Check SMS inbox
|
|
502
|
-
const inbox = await agent.smsInboxList({ limit: 10 });
|
|
503
|
-
for (const msg of inbox.messages) {
|
|
504
|
-
console.log(`From ${msg.from}: ${msg.body}`);
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
// Get specific message
|
|
508
|
-
const msg = await agent.smsInboxGet('msg_abc123');
|
|
509
|
-
```
|
|
510
|
-
|
|
511
|
-
### Email with Attachments
|
|
512
|
-
|
|
513
|
-
```typescript
|
|
514
|
-
await agent.email({
|
|
515
|
-
to: ['alice@example.com', 'bob@example.com'],
|
|
516
|
-
subject: 'Report',
|
|
517
|
-
body: 'See attached.',
|
|
518
|
-
attachments: [{
|
|
519
|
-
filename: 'report.pdf',
|
|
520
|
-
content: base64Content,
|
|
521
|
-
content_type: 'application/pdf'
|
|
522
|
-
}]
|
|
523
|
-
});
|
|
524
|
-
```
|
|
525
|
-
|
|
526
|
-
### Custom Sender (name, mailbox, domain)
|
|
527
|
-
|
|
528
|
-
```typescript
|
|
529
|
-
// Renders as: From: Jane Doe <jane@acme.com>
|
|
530
|
-
await agent.email({
|
|
531
|
-
to: 'user@example.com',
|
|
532
|
-
subject: 'Hello',
|
|
533
|
-
body: 'Sent from a custom sender.',
|
|
534
|
-
from_name: 'Jane Doe', // display name (optional)
|
|
535
|
-
from_mailbox: 'jane', // local-part, defaults to "agent"; requires from_domain
|
|
536
|
-
from_domain: 'acme.com' // must be a domain you own
|
|
537
|
-
});
|
|
538
|
-
```
|
|
539
|
-
|
|
540
|
-
`from_domain` must be a domain you've provisioned through OneShot. Pinning
|
|
541
|
-
`from_mailbox` without `from_domain` throws a client-side `ValidationError` —
|
|
542
|
-
there is no default domain to fall back to; omit both to rotate instead.
|
|
543
|
-
|
|
544
|
-
**Dedicated mailboxes:** pass `mailbox_mode: 'mailbox'` when **first provisioning
|
|
545
|
-
a new `from_domain`** to give each address a real dedicated mailbox (better
|
|
546
|
-
deliverability + per-address warmup) instead of the default `relay` (header-only)
|
|
547
|
-
send; it adds a one-time `mailbox_provisioning_fee` to the quote. It only applies
|
|
548
|
-
at first setup — an already-provisioned domain keeps the mode it was created with,
|
|
549
|
-
and requesting `mailbox` on an existing relay domain returns
|
|
550
|
-
`400 mailbox_mode_conflict`.
|
|
551
|
-
|
|
552
|
-
### Domain Pool & Warmup
|
|
553
|
-
|
|
554
|
-
OneShot runs a per-agent **domain pool** with server-side warmup so your cold
|
|
555
|
-
email lands in the inbox. Understanding pin-vs-rotate is the key concept:
|
|
556
|
-
|
|
557
|
-
- **Rotate (recommended for cold outreach):** omit both `from_domain` and
|
|
558
|
-
`from_mailbox`. The server picks a warmed, under-cap domain **from your own
|
|
559
|
-
pool**, applies warmup-score and daily-limit gates, and returns the chosen
|
|
560
|
-
address on the quote (`quote.from_address`). This is the only mode that gets
|
|
561
|
-
warmup protection. If you own no eligible domain, the quote returns
|
|
562
|
-
**`400 no_sending_domain`** — there is **no shared fallback sender**; you must
|
|
563
|
-
provision/own a domain to send.
|
|
564
|
-
- **Pin:** set the required `from_domain` and optionally `from_mailbox` to select a sender. `from_mailbox` cannot be used alone.
|
|
565
|
-
Rotation is bypassed — **and so are the warmup-score and daily-limit gates.**
|
|
566
|
-
Pinning a still-warming or over-cap domain will hurt deliverability; the send
|
|
567
|
-
still goes out, but the response carries a non-blocking `warning` (see below).
|
|
568
|
-
|
|
569
|
-
**Reputation is per-domain**, shared by every mailbox on it. Running multiple
|
|
570
|
-
mailboxes on one domain (`jane@`, `sales@`, …) does **not** improve
|
|
571
|
-
deliverability or raise capacity — they share the same warmup score and the same
|
|
572
|
-
`daily_send_limit`.
|
|
573
|
-
|
|
574
|
-
**Provisioning:** a domain enters your pool the first time you reference it in a
|
|
575
|
-
send/quote (auto-provisioned, then `provisioning → verified → warming → active`
|
|
576
|
-
once its warmup score crosses the activation threshold). There is no separate
|
|
577
|
-
provisioning call today. New domains start in `warming` and aren't rotation-
|
|
578
|
-
eligible until they graduate.
|
|
579
|
-
|
|
580
|
-
**The `warning` field** (non-blocking — the send still happens; read it to defer):
|
|
581
|
-
|
|
582
|
-
| `warning` | Meaning |
|
|
583
|
-
|-----------|---------|
|
|
584
|
-
| `pinned_domain_warming` | Your pinned domain is still warming (low warmup score) — poor deliverability likely. |
|
|
585
|
-
| `pinned_over_limit` | Your pinned domain is over its `daily_send_limit` for today. |
|
|
586
|
-
|
|
587
|
-
Pinned sends are never blocked by warmup/limit — branch on `warning` and defer.
|
|
588
|
-
(The one hard error is `400 no_sending_domain` on an **un-pinned** send when you
|
|
589
|
-
own no eligible domain — provision or pin one.)
|
|
590
|
-
|
|
591
|
-
```typescript
|
|
592
|
-
// Inspect and manage the pool
|
|
593
|
-
const { domains } = await agent.listDomains();
|
|
594
|
-
// each: { domain, pool_status, warmup_score, daily_send_limit, daily_sent_count, ... }
|
|
595
|
-
|
|
596
|
-
await agent.pauseDomain('acme.com'); // take out of rotation
|
|
597
|
-
await agent.resumeDomain('acme.com'); // put back (only from 'paused')
|
|
598
|
-
|
|
599
|
-
const res = await agent.email({ to: 'lead@example.com', subject: 'Hi', body: '…' });
|
|
600
|
-
if (res.warning) {
|
|
601
|
-
// e.g. 'pinned_domain_warming' — back off and let warmup finish
|
|
602
|
-
}
|
|
603
|
-
```
|
|
604
|
-
|
|
605
|
-
### People Search & Enrichment
|
|
606
|
-
|
|
607
|
-
```typescript
|
|
608
|
-
const results = await agent.personFind({
|
|
609
|
-
job_titles: ['CEO', 'CTO'],
|
|
610
|
-
companies: ['Stripe'],
|
|
611
|
-
limit: 10
|
|
612
|
-
});
|
|
613
|
-
|
|
614
|
-
const profile = await agent.personProfile({
|
|
615
|
-
linkedin_url: results.results[0].linkedin_url
|
|
616
|
-
});
|
|
617
|
-
```
|
|
618
|
-
|
|
619
|
-
**Filters:** `seniority` takes any of `owner`, `founder`, `c_suite`, `partner`, `vp`, `head`, `director`, `manager`, `senior`, `entry`, `intern`.
|
|
620
|
-
Common variants (`'Vice President'`, `'C-Level'`, `'executive'`) are accepted;
|
|
621
|
-
a value that matches no level fails the search with `invalid_input`. `industry`
|
|
622
|
-
is free text (`['fintech', 'software']`).
|
|
623
|
-
|
|
624
|
-
**Empty vs. failed:** an empty `results` array means the search ran and nobody
|
|
625
|
-
matched. If the search could not be run, the call throws a `JobError` with a
|
|
626
|
-
retryable upstream code (`service_unavailable`, `service_auth`,
|
|
627
|
-
`rate_limited`) instead of returning an empty result.
|
|
628
|
-
|
|
629
|
-
**Pagination:** `limit` (default 100, max 500) and `offset` (default 0,
|
|
630
|
-
0-indexed) page through the result set — `{ limit: 100, offset: 100 }` gets
|
|
631
|
-
the second page of 100. Large requests are paginated server-side, so one
|
|
632
|
-
response can hold up to `limit` rows. The search runs under a time limit: if it
|
|
633
|
-
is reached, you get the rows found so far (possibly fewer than `limit`) and can
|
|
634
|
-
continue with `offset`. Rows whose phone lookup did not finish in time are
|
|
635
|
-
returned with `_phone_enriched: false` and
|
|
636
|
-
`_phone_enrich_reason: 'time_budget_exhausted'` rather than dropped.
|
|
637
|
-
|
|
638
|
-
```typescript
|
|
639
|
-
const page2 = await agent.personFind({
|
|
640
|
-
job_titles: ['CEO'],
|
|
641
|
-
limit: 100,
|
|
642
|
-
offset: 100
|
|
643
|
-
});
|
|
644
|
-
```
|
|
645
|
-
|
|
646
|
-
### Commerce
|
|
647
|
-
|
|
648
|
-
```typescript
|
|
649
|
-
const order = await agent.commerceBuy({
|
|
650
|
-
product_url: 'https://amazon.com/dp/B07ZPC9QD4',
|
|
651
|
-
shipping_address: {
|
|
652
|
-
first_name: 'John',
|
|
653
|
-
last_name: 'Doe',
|
|
654
|
-
street: '123 Main St',
|
|
655
|
-
city: 'San Francisco',
|
|
656
|
-
state: 'CA',
|
|
657
|
-
zip_code: '94102',
|
|
658
|
-
country: 'US',
|
|
659
|
-
phone: '4155550100'
|
|
660
|
-
},
|
|
661
|
-
maxCost: 100
|
|
662
|
-
});
|
|
663
|
-
```
|
|
664
|
-
|
|
665
|
-
### Physical mail
|
|
666
|
-
|
|
667
|
-
`agent.physicalMail` exposes `uploadArtwork`, `validateAddress`, `preview`, `getQuote`, `approve`, `send`, `getOrder`, `recover`, and `cancel` for U.S. letters and 4×6 postcards. Inspect the proof and price before explicitly approving each quote. Persist `idempotencyKey` before `send`; use `recover(key)` after uncertain responses. Approval is never inferred by automatic payment retries. Payment receipts and postal events are separate; delivery does not prove readership. See `docs/physical-mail.md` in the OneShot repository for configuration and examples.
|
|
668
|
-
|
|
669
|
-
### Account login and 2FA (SDK 0.34.0+; `createBrowserProfileSetupLink` from 0.54.0)
|
|
670
|
-
|
|
671
|
-
Create a browser profile, then:
|
|
672
|
-
|
|
673
|
-
1. Start: `startBrowserProfileSetup(profile.id, loginUrl)`.
|
|
674
|
-
2. Give the returned `setup_url` to the person whose account it is. It opens once and expires after 10 minutes; `createBrowserProfileSetupLink(profile.id)` mints a fresh one, and with a `startUrl` it also starts a setup when none is open.
|
|
675
|
-
3. The person signs in on the page, completes the site's verification, and presses **Done**. **Cancel** ends the setup without marking it complete, so `completed_at` stays `null`.
|
|
676
|
-
4. Poll `getBrowserProfileSetup(profile.id)` until `completed_at` is set, or until `status` is `expired`, `no_setup` or `stopped` (the setup ended after Cancel or the 15-minute expiry; `completed_at` stays `null`, so stop polling and start setup again). Once `completed_at` is set, store the profile ID for later `browser({ profile_id, task })` calls.
|
|
677
|
-
|
|
678
|
-
Done (or `finishBrowserProfileSetup(profile.id)`, when your application saves on the person's behalf) stops the session and inspects cookies in a fresh browser before website navigation. It returns cookie names/domains/paths, never values; a subsequent task must check whether the site accepts the login. Setup expires after 15 minutes and abandoned sessions are closed by the lifecycle sweep. Profiles are retained. Start setup again to reconnect an expired site login.
|
|
679
|
-
|
|
680
|
-
Treat `setup_url` as a secret: give it only to that person, never open it yourself, and keep it, passwords and codes out of logs and agent prompts. The page is not cached and sends no referrer. `live_url` is deprecated and is removed in the next release.
|
|
681
|
-
|
|
682
|
-
Browser tasks reject the legacy `secrets` field and `max_steps` below 25 before payment. Use interactive setup or `createBrowserProfile(name, { cookies })` / `{ storage_state }` for authentication. `cost` is the provider cost; `billed_cost` is the final customer charge after reconciliation (null while pending). Failed `JobError`s expose `partialResult` for diagnostics.
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
### LinkedIn invitations and withdrawal
|
|
686
|
-
|
|
687
|
-
Available in `@oneshot-agent/sdk` 0.38.0 and later. Both operations require a connected account with the `invite` grant.
|
|
688
|
-
|
|
689
|
-
```typescript
|
|
690
|
-
const invitation = await agent.linkedinInvite({
|
|
691
|
-
accountId,
|
|
692
|
-
profile: 'https://www.linkedin.com/in/jane-doe/',
|
|
693
|
-
note: 'Enjoyed your presentation.',
|
|
694
|
-
idempotencyKey: 'event-jane-invite',
|
|
695
|
-
});
|
|
696
|
-
|
|
697
|
-
// To withdraw that pending invitation later:
|
|
698
|
-
await agent.linkedinWithdrawInvitation({
|
|
699
|
-
accountId,
|
|
700
|
-
invitationId: invitation.invitation_id,
|
|
701
|
-
idempotencyKey: 'event-jane-withdraw',
|
|
702
|
-
});
|
|
703
|
-
```
|
|
704
|
-
|
|
705
|
-
Use the OneShot `invitation_id`, not the provider invitation ID. Withdrawal can also cancel a queued invitation; it never disconnects an established connection. Invitations default to 25 per account per UTC day, and withdrawing a sent invitation does not restore that day's capacity. Reuse the same idempotency key when retrying an operation.
|
|
706
|
-
|
|
707
|
-
### Recovering a missing LinkedIn connection
|
|
708
|
-
|
|
709
|
-
Use `reconnectLinkedInAccount(id)` for an existing upstream connection whose session needs renewal. A deleted upstream account needs a new `linkedinConnect()` intent and fresh human authorization.
|
|
710
|
-
|
|
711
|
-
Account reads refresh disconnected accounts against the provider. Once an upstream account-read confirms `404`, the old connection is marked `connection_deleted`, its grant is ended, and `reconnect_required` is false. It is omitted from the default active account list; use `includeRevoked: true` or fetch it by ID to inspect its terminal status. Authentication failures, timeouts, and provider outages do not trigger this transition.
|
|
712
|
-
|
|
713
|
-
```ts
|
|
714
|
-
import { LinkedInConnectRequiredError } from '@oneshot-agent/sdk';
|
|
715
|
-
|
|
716
|
-
try {
|
|
717
|
-
const intent = await agent.reconnectLinkedInAccount(account.id);
|
|
718
|
-
// Show intent.url to the human.
|
|
719
|
-
} catch (error) {
|
|
720
|
-
if (error instanceof LinkedInConnectRequiredError) {
|
|
721
|
-
// Show “Connect LinkedIn” and ask the human to choose grants again.
|
|
722
|
-
// On confirmation, call agent.linkedinConnect({ requestedActions: ['read'] }).
|
|
723
|
-
} else {
|
|
724
|
-
throw error;
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
```
|
|
728
|
-
|
|
729
|
-
The HTTP equivalent is `409` with `error: "connect_required"` and `details.next_action: "connect"`. Existing SDK versions can inspect `ToolError.responseBody` for this contract.
|
|
730
|
-
### Notifications
|
|
731
|
-
|
|
732
|
-
```typescript
|
|
733
|
-
// List notifications
|
|
734
|
-
const notifications = await agent.notifications({ unread: true, limit: 20 });
|
|
735
|
-
for (const n of notifications.notifications) {
|
|
736
|
-
console.log(`[${n.type}] ${n.title}: ${n.message}`);
|
|
737
|
-
}
|
|
738
|
-
|
|
739
|
-
// Mark as read
|
|
740
|
-
await agent.markNotificationRead('notification-uuid');
|
|
741
|
-
```
|
|
742
|
-
|
|
743
|
-
### Cancellation
|
|
744
|
-
|
|
745
|
-
Use `AbortSignal` to cancel operations **before payment is made**. Once payment is signed, the operation will execute regardless of cancellation.
|
|
746
|
-
|
|
747
|
-
```typescript
|
|
748
|
-
const controller = new AbortController();
|
|
749
|
-
|
|
750
|
-
// Cancel after 5 seconds if still in quote phase
|
|
751
|
-
setTimeout(() => controller.abort(), 5000);
|
|
752
|
-
|
|
753
|
-
try {
|
|
754
|
-
await agent.voice({
|
|
755
|
-
objective: 'Make a reservation',
|
|
756
|
-
target_number: '+14155551234',
|
|
757
|
-
signal: controller.signal
|
|
758
|
-
});
|
|
759
|
-
} catch (error) {
|
|
760
|
-
if (error.message === 'Operation cancelled before payment') {
|
|
761
|
-
console.log('Cancelled before paying - no charge');
|
|
762
|
-
}
|
|
763
|
-
}
|
|
764
|
-
```
|
|
765
|
-
|
|
766
|
-
**Important:** The signal can cancel:
|
|
767
|
-
- Quote requests (before receiving price)
|
|
768
|
-
- The decision phase (after quote, before payment)
|
|
769
|
-
|
|
770
|
-
The signal **cannot** cancel:
|
|
771
|
-
- Operations after payment is signed (call/SMS will still execute)
|
|
772
|
-
- Server-side job execution
|
|
125
|
+
- `JobError.code` is one of `insufficient_funds` `payment_failed` `invalid_input`
|
|
126
|
+
`content_blocked` `rate_limited` `service_unavailable` `service_auth`
|
|
127
|
+
`enrichment_exhausted` `target_unreachable` `source_unsupported`
|
|
128
|
+
`checkout_failed` `internal_error`. [What each means](https://docs.oneshotagent.com/api-reference/status#error-codes).
|
|
129
|
+
- Input the SDK can check throws `ValidationError` before anything is paid.
|
|
130
|
+
- Emergency numbers are refused: `EmergencyNumberError`.
|
|
131
|
+
|
|
132
|
+
## Waiting and stopping
|
|
133
|
+
|
|
134
|
+
- Paid calls wait by default. `wait: false` returns the `request_id`;
|
|
135
|
+
`waitForResult(requestId)` picks the result up later.
|
|
136
|
+
- An `AbortSignal` stops the call **before payment** and nothing is charged.
|
|
137
|
+
After payment, the work happens and is billed. Aborting only stops your wait.
|
|
138
|
+
- An abort rejects with `OneShotError('Operation cancelled')` for `commerceBuy`,
|
|
139
|
+
`voice`, `sms`, `build`, `refineBuild`, `updateBuild` and `browser`; the other
|
|
140
|
+
calls reject with the signal's `reason`. Handle both.
|
|
141
|
+
- `timeout` is how long you wait, in seconds. It never limits the job.
|
|
142
|
+
- Goals run longer than calls. Watch one with `waitForComputeGoal`:
|
|
143
|
+
|
|
144
|
+
```typescript
|
|
145
|
+
const goal = await agent.compute({ objective: 'Research battery recycling', budget_usdc: 5 });
|
|
146
|
+
const done = await agent.waitForComputeGoal(goal.goal_id, {
|
|
147
|
+
timeout: 300,
|
|
148
|
+
onStatusUpdate: (status) => console.log(status),
|
|
149
|
+
});
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
- It resolves on `completed` and throws `JobError` on `failed` or `cancelled`
|
|
153
|
+
(`code` is the `end_reason`). `awaiting_confirmation` and `paused` wait for you;
|
|
154
|
+
they do not end the wait.
|
|
155
|
+
- A goal that failed with `budget_exhausted` comes back after `fundComputeGoal`.
|
|
156
|
+
Call `waitForComputeGoal` again; the old wait does not resume.
|
|
157
|
+
- Timeout defaults to 120 seconds and throws `JobTimeoutError`. It stops your
|
|
158
|
+
polling, not the goal. Stop the goal with `cancelComputeGoal`.
|
|
159
|
+
|
|
160
|
+
## Tool notes
|
|
161
|
+
|
|
162
|
+
- **Email.** Omit `from_domain` and the server rotates across your warmed
|
|
163
|
+
domains. Pin one and you skip the warmup gates; the send goes out with a
|
|
164
|
+
`warning`. Own no eligible domain and the quote fails with `no_sending_domain`.
|
|
165
|
+
There is no shared sender. `mailbox_mode: 'mailbox'` applies only when a domain
|
|
166
|
+
is first set up. [Details](https://docs.oneshotagent.com/api-reference/email/send).
|
|
167
|
+
- **People search.** An empty result means nobody matched. A failed search
|
|
168
|
+
throws; it never pretends to be empty. Page with `limit` (default 100, max 500)
|
|
169
|
+
and `offset`. A search that hits its time limit returns what it found; rows
|
|
170
|
+
whose phone lookup ran out of time say `_phone_enrich_reason: 'time_budget_exhausted'`.
|
|
171
|
+
[Details](https://docs.oneshotagent.com/api-reference/research/person-find).
|
|
172
|
+
- **Phone lookup** is off by default. `includePhone: true` is charged for each person
|
|
173
|
+
you ask for (the search `limit`), found or not; a failed job is refunded. `waitForPhones: true` waits
|
|
174
|
+
for numbers still arriving. It never buys any. Check `phones_pending`.
|
|
175
|
+
[Price](https://docs.oneshotagent.com/pricing).
|
|
176
|
+
- **Account login.** `startBrowserProfileSetup` returns a `setup_url`. It opens
|
|
177
|
+
once and expires in 10 minutes. Give it only to the account's owner, never open
|
|
178
|
+
it yourself, keep it out of logs and prompts. Poll `getBrowserProfileSetup`
|
|
179
|
+
until `completed_at` is set. You get cookie names back, never values.
|
|
180
|
+
[Details](https://docs.oneshotagent.com/api-reference/browser/profiles).
|
|
181
|
+
- **LinkedIn.** Invitations are capped at 25 per account per UTC day;
|
|
182
|
+
withdrawing one does not give the slot back. Use OneShot's `invitation_id`.
|
|
183
|
+
A session that expired comes back with `reconnectLinkedInAccount`; a deleted
|
|
184
|
+
account throws `LinkedInConnectRequiredError` and needs `linkedinConnect` again.
|
|
185
|
+
Reuse your idempotency key on retries. [Details](https://docs.oneshotagent.com/api-reference/linkedin/overview).
|
|
186
|
+
- **Physical mail.** U.S. letters and postcards. Look at the proof and the price,
|
|
187
|
+
then approve each quote yourself. Nothing approves it for you. Persist the
|
|
188
|
+
`idempotencyKey` before `send`. [Details](https://docs.oneshotagent.com/api-reference/physical-mail/overview).
|
|
773
189
|
|
|
774
190
|
## Links
|
|
775
191
|
|
|
776
192
|
- [Documentation](https://docs.oneshotagent.com)
|
|
777
|
-
- [MCP Server](https://www.npmjs.com/package/@oneshot-agent/mcp-server)
|
|
778
|
-
- [Python SDK (LangChain)](https://pypi.org/project/langchain-oneshot/)
|
|
779
|
-
- [Python SDK (Core)](https://pypi.org/project/oneshot-python/)
|
|
193
|
+
- [MCP Server](https://www.npmjs.com/package/@oneshot-agent/mcp-server): local, or hosted at `https://win.oneshotagent.com/mcp` with an access token
|
|
194
|
+
- [Python SDK (LangChain)](https://pypi.org/project/langchain-oneshot/): 52 tools plus the lookup tools as LangChain BaseTool
|
|
195
|
+
- [Python SDK (Core)](https://pypi.org/project/oneshot-python/)
|
|
780
196
|
- [Pricing](https://docs.oneshotagent.com/pricing)
|
|
781
197
|
- [GitHub](https://github.com/oneshot-agent/sdk)
|
|
782
198
|
|
|
783
199
|
## License
|
|
784
200
|
|
|
785
201
|
MIT
|
|
786
|
-
|
|
787
|
-
## Optional phone lookup
|
|
788
|
-
|
|
789
|
-
Phone lookup is off by default. Source-returned numbers and published business or record numbers still appear. `includePhone: true` adds the per-person add-on listed on the pricing page × the requested search limit (default 100) for a search, or once for profile/dossier, for up to that many people with no guaranteed hit. Fallbacks and callbacks cost nothing extra. A completed lookup with no phone match is charged; a failed job is refunded.
|
|
790
|
-
|
|
791
|
-
`maxCost` and per-transaction budgets apply to the full quote before authorization, even when credits cover it. The SDK obtains the quote without execution, retries with its quote ID and payment or credit session, and returns the result and receipt.
|
|
792
|
-
|
|
793
|
-
```typescript
|
|
794
|
-
const people = await agent.personFind({ job_titles: ['CTO'], limit: 3, includePhone: true, maxCost: 1, waitForPhones: true });
|
|
795
|
-
const profile = await agent.personProfile({ email: 'jane@example.com', includePhone: true, maxCost: 1, waitForPhones: true });
|
|
796
|
-
const dossier = await agent.personDossier({ email: 'jane@example.com', includePhone: true, maxCost: 1, waitForPhones: true, timeout: 600 });
|
|
797
|
-
```
|
|
798
|
-
|
|
799
|
-
`waitForPhones` waits for pending callbacks; it does not purchase phones by itself. On timeout the latest result can still have `phones_pending: true`.
|