@rtrvr-ai/sdk 0.1.0 → 0.2.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.
Files changed (2) hide show
  1. package/README.md +165 -0
  2. package/package.json +2 -2
package/README.md ADDED
@@ -0,0 +1,165 @@
1
+ # @rtrvr-ai/sdk
2
+
3
+ Official TypeScript SDK for RTRVR APIs. It wraps `@rtrvr-ai/core` with a higher-level interface and re-exports all core types and helpers.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @rtrvr-ai/sdk
9
+ ```
10
+
11
+ ## Requirements
12
+
13
+ - Node.js 18+
14
+ - ESM (`"type": "module"`)
15
+
16
+ ## Quickstart
17
+
18
+ ```ts
19
+ import { createRtrvrClient } from '@rtrvr-ai/sdk';
20
+
21
+ const client = createRtrvrClient({
22
+ apiKey: process.env.RTRVR_API_KEY!,
23
+ defaultTarget: 'auto',
24
+ });
25
+
26
+ const result = await client.run({
27
+ input: 'Find the latest pricing',
28
+ urls: ['https://example.com'],
29
+ });
30
+
31
+ console.log(result.metadata, result.data);
32
+ ```
33
+
34
+ ## Common operations
35
+
36
+ ```ts
37
+ // Unified run with auto-routing
38
+ const result = await client.run({
39
+ input: 'Find the latest pricing',
40
+ urls: ['https://example.com'],
41
+ target: 'auto', // or 'cloud' or 'extension'
42
+ });
43
+
44
+ // Agent operations
45
+ const agent = await client.agent.run({
46
+ input: 'Summarize the page',
47
+ urls: ['https://example.com'],
48
+ schema: { fields: [...] }, // optional structured output
49
+ });
50
+
51
+ // Cloud-only agent (requires rtrvr_ API key)
52
+ const cloud = await client.agent.cloud({
53
+ input: 'Summarize the page',
54
+ urls: ['https://example.com'],
55
+ });
56
+
57
+ // Scraping
58
+ const scrape = await client.scrape.route({
59
+ urls: ['https://example.com'],
60
+ target: 'auto',
61
+ });
62
+
63
+ // Extension-specific operations
64
+ const extensionResult = await client.extension.run({
65
+ input: 'Click the login button',
66
+ urls: ['https://example.com'],
67
+ deviceId: 'my-device',
68
+ });
69
+
70
+ // MCP tool helpers
71
+ const extracted = await client.tools.extract({
72
+ user_input: 'Extract product names and prices',
73
+ tab_urls: ['https://example.com/products'],
74
+ });
75
+
76
+ const acted = await client.tools.act({
77
+ user_input: 'Fill the form with user data',
78
+ tab_urls: ['https://example.com/form'],
79
+ });
80
+
81
+ const crawled = await client.tools.crawl({
82
+ user_input: 'Extract all product listings',
83
+ tab_urls: ['https://example.com/catalog'],
84
+ });
85
+
86
+ const planned = await client.tools.planner({
87
+ user_input: 'Navigate to settings and update profile',
88
+ tab_urls: ['https://example.com'],
89
+ });
90
+
91
+ // Raw tool execution
92
+ const toolResult = await client.tools.run({
93
+ tool: 'get_page_data',
94
+ params: { tabIds: [123] },
95
+ deviceId: 'my-device',
96
+ });
97
+
98
+ // Devices and credits
99
+ const devices = await client.devices.list();
100
+ const credits = await client.credits.get();
101
+
102
+ // Profile and capabilities
103
+ const profile = await client.profile.get();
104
+ const capabilities = await client.profile.capabilities();
105
+ ```
106
+
107
+ ## Auth tokens
108
+
109
+ - `rtrvr_...` API keys can access cloud + MCP + control endpoints.
110
+ - `mcp_at_...` tokens are limited to MCP endpoints. Cloud calls throw an error.
111
+
112
+ ## Low-level access
113
+
114
+ You can always drop down to the raw client:
115
+
116
+ ```ts
117
+ const raw = client.raw;
118
+ const response = await raw.toolRun({ tool: 'list_devices', params: {} });
119
+ ```
120
+
121
+ ## Advanced options
122
+
123
+ ### Request configuration
124
+
125
+ ```ts
126
+ // Full request with all options
127
+ const result = await client.run({
128
+ input: 'Extract product data',
129
+ urls: ['https://example.com'],
130
+ schema: { fields: [...] }, // structured output schema
131
+ files: [{ displayName, uri, mimeType }], // file inputs
132
+ fileUrls: ['https://...'], // file URLs for context
133
+ dataInputs: [...], // additional data
134
+ settings: { llmIntegration: {...} }, // agent settings
135
+ tools: { enabledTools: [...] }, // tool configuration
136
+ options: { ui: { emitEvents: true } }, // execution options
137
+ response: {
138
+ verbosity: 'steps', // 'final' | 'steps' | 'debug'
139
+ inlineOutputMaxBytes: 50000,
140
+ },
141
+ webhooks: [{
142
+ url: 'https://your-webhook.com',
143
+ events: ['tool_complete', 'workflow_complete'],
144
+ auth: { type: 'bearer', token: 'xxx' },
145
+ }],
146
+ trajectoryId: 'custom-id', // workflow tracking
147
+ phase: 1, // workflow phase
148
+ authToken: 'google-oauth-token', // for Drive/Docs/Sheets
149
+ target: 'auto', // routing mode
150
+ preferExtension: true, // prefer extension in auto
151
+ requireLocalSession: false, // require extension or fail
152
+ deviceId: 'my-device', // target device
153
+ });
154
+ ```
155
+
156
+ ## What it exports
157
+
158
+ `@rtrvr-ai/sdk` re-exports everything from `@rtrvr-ai/core`, including:
159
+
160
+ - `RtrvrClient` - low-level client
161
+ - `RtrvrError` - error class with status and requestId
162
+ - `createRtrvrClient` - SDK factory function
163
+ - Request/response types: `UnifiedRunRequest`, `UnifiedRunResponse`, `UnifiedScrapeRequest`, etc.
164
+ - Helper types: `CloudFile`, `WebhookSubscription`, `WebhookAuth`, `DeviceInfo`, `RunMetadata`
165
+ - All type exports from core
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtrvr-ai/sdk",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Official TypeScript SDK for rtrvr APIs (/agent, /scrape, /mcp)",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -38,7 +38,7 @@
38
38
  "access": "public"
39
39
  },
40
40
  "dependencies": {
41
- "@rtrvr-ai/core": "0.1.0"
41
+ "@rtrvr-ai/core": "0.2.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "tsup": "^8.5.0",