@youdotcom-oss/api 0.0.1
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 +551 -0
- package/bin/cli.js +5483 -0
- package/package.json +68 -0
- package/src/cli.ts +98 -0
- package/src/commands/contents.ts +52 -0
- package/src/commands/express.ts +52 -0
- package/src/commands/search.ts +52 -0
- package/src/contents/contents.schemas.ts +46 -0
- package/src/contents/contents.utils.ts +98 -0
- package/src/contents/tests/contents.utils.spec.ts +78 -0
- package/src/express/express.schemas.ts +77 -0
- package/src/express/express.utils.ts +113 -0
- package/src/express/tests/express.utils.spec.ts +83 -0
- package/src/main.ts +22 -0
- package/src/search/search.schemas.ts +110 -0
- package/src/search/search.utils.ts +80 -0
- package/src/search/tests/search.utils.spec.ts +135 -0
- package/src/shared/api.constants.ts +10 -0
- package/src/shared/api.types.ts +1 -0
- package/src/shared/check-response-for-errors.ts +13 -0
- package/src/shared/generate-error-report-link.ts +35 -0
- package/src/shared/tests/check-response-for-errors.spec.ts +31 -0
- package/src/shared/tests/format-search-results-text.spec.ts +85 -0
- package/src/shared/use-get-user-agents.ts +8 -0
package/README.md
ADDED
|
@@ -0,0 +1,551 @@
|
|
|
1
|
+
# @youdotcom-oss/api
|
|
2
|
+
|
|
3
|
+
> You.com API client with bundled CLI for AI agents that can use bash commands
|
|
4
|
+
|
|
5
|
+
Fast, lightweight API client and CLI tools for web search, AI answers, and content extraction. Optimized for AI agents supporting the [Agent Skills Spec](https://agentskills.io/home) with built-in support for calling bash commands.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **⚡ Faster than builtin search APIs** - Optimized infrastructure for agent workloads
|
|
10
|
+
- **🔄 Livecrawl** - Search AND extract content in one API call
|
|
11
|
+
- **✅ Verifiable references** - Every result includes citation URLs
|
|
12
|
+
- **📱 Agent skills optimized** - JSON output for bash pipelines (jq, grep, awk)
|
|
13
|
+
- **🛠️ Dual interface** - CLI tools AND programmatic TypeScript API
|
|
14
|
+
- **🪶 Lightweight** - No heavy dependencies, just Zod for validation
|
|
15
|
+
|
|
16
|
+
## Quick Start
|
|
17
|
+
|
|
18
|
+
### CLI Usage
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# Use with bunx (no install needed) - Schema-driven JSON input
|
|
22
|
+
bunx @youdotcom-oss/api search --json '{"query":"AI developments"}' --client Openclaw
|
|
23
|
+
|
|
24
|
+
# Or install globally to use 'ydc' command
|
|
25
|
+
bun i -g @youdotcom-oss/api
|
|
26
|
+
ydc search --json '{"query":"AI developments"}' --client Openclaw
|
|
27
|
+
|
|
28
|
+
# Get AI answer with citations
|
|
29
|
+
bunx @youdotcom-oss/api express --json '{
|
|
30
|
+
"input":"What happened in AI this week?",
|
|
31
|
+
"tools":[{"type":"web_search"}]
|
|
32
|
+
}' --client MyAgent
|
|
33
|
+
|
|
34
|
+
# Extract web content
|
|
35
|
+
bunx @youdotcom-oss/api contents --json '{
|
|
36
|
+
"urls":["https://example.com"],
|
|
37
|
+
"formats":["markdown"]
|
|
38
|
+
}' --client MyAgent
|
|
39
|
+
|
|
40
|
+
# Discover available parameters with --schema
|
|
41
|
+
api search --schema | jq '.properties | keys'
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Programmatic Usage
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
import { fetchSearchResults } from '@youdotcom-oss/api';
|
|
48
|
+
|
|
49
|
+
const getUserAgent = (client: string) => `MyApp/${client} (You.com; 1.0.0)`;
|
|
50
|
+
|
|
51
|
+
const results = await fetchSearchResults({
|
|
52
|
+
searchQuery: { query: 'AI developments', livecrawl: 'web' },
|
|
53
|
+
YDC_API_KEY: process.env.YDC_API_KEY,
|
|
54
|
+
getUserAgent,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
console.log(results.results.web);
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Installation
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
# Bun (recommended for CLI)
|
|
64
|
+
bun add @youdotcom-oss/api
|
|
65
|
+
|
|
66
|
+
# npm
|
|
67
|
+
npm install @youdotcom-oss/api
|
|
68
|
+
|
|
69
|
+
# yarn
|
|
70
|
+
yarn add @youdotcom-oss/api
|
|
71
|
+
|
|
72
|
+
# pnpm
|
|
73
|
+
pnpm add @youdotcom-oss/api
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
**Global installation for CLI:**
|
|
77
|
+
```bash
|
|
78
|
+
bun i -g @youdotcom-oss/api
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Setup
|
|
82
|
+
|
|
83
|
+
**Get API Key:**
|
|
84
|
+
1. Visit https://you.com/platform/api-keys
|
|
85
|
+
2. Create new API key
|
|
86
|
+
3. Set environment variable:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
export YDC_API_KEY="your-api-key"
|
|
90
|
+
export YDC_CLIENT="YourAgentName" # Optional: default client for tracking
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## CLI Reference
|
|
94
|
+
|
|
95
|
+
**Schema-driven JSON input**: This CLI is optimized for AI agents using bash commands. All query parameters are passed as JSON via the required `--json` flag.
|
|
96
|
+
|
|
97
|
+
### Commands
|
|
98
|
+
|
|
99
|
+
All commands require the `--json` flag with a JSON string containing the query parameters:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
api search --json '{"query":"..."}'
|
|
103
|
+
api express --json '{"input":"..."}'
|
|
104
|
+
api contents --json '{"urls":["..."]}'
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Global Options
|
|
108
|
+
|
|
109
|
+
- `--json <json>` - **Required**. JSON string with command parameters
|
|
110
|
+
- `--api-key <key>` - You.com API key (overrides YDC_API_KEY)
|
|
111
|
+
- `--client <name>` - Client name for tracking (overrides YDC_CLIENT)
|
|
112
|
+
- `--schema` - Output JSON schema for what can be passed to --json
|
|
113
|
+
- `--help, -h` - Show help
|
|
114
|
+
|
|
115
|
+
### Schema Discovery
|
|
116
|
+
|
|
117
|
+
Use `--schema` to discover what parameters each command accepts:
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
# Get schema for search command
|
|
121
|
+
api search --schema
|
|
122
|
+
|
|
123
|
+
# Get schema for express command
|
|
124
|
+
api express --schema
|
|
125
|
+
|
|
126
|
+
# Get schema for contents command
|
|
127
|
+
api contents --schema
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
The schema output describes the JSON structure to pass via `--json`.
|
|
131
|
+
|
|
132
|
+
### Search Command
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
api search --json '{"query":"..."}' [options]
|
|
136
|
+
|
|
137
|
+
Examples:
|
|
138
|
+
# Basic search
|
|
139
|
+
api search --json '{"query":"machine learning"}' --client Openclaw
|
|
140
|
+
|
|
141
|
+
# Search with livecrawl (KEY FEATURE)
|
|
142
|
+
api search --json '{
|
|
143
|
+
"query":"documentation",
|
|
144
|
+
"livecrawl":"web",
|
|
145
|
+
"livecrawl_formats":"markdown"
|
|
146
|
+
}' --client Openclaw
|
|
147
|
+
|
|
148
|
+
# Advanced filters
|
|
149
|
+
api search --json '{
|
|
150
|
+
"query":"AI papers",
|
|
151
|
+
"site":"arxiv.org",
|
|
152
|
+
"fileType":"pdf",
|
|
153
|
+
"freshness":"month",
|
|
154
|
+
"count":10
|
|
155
|
+
}' --client Openclaw
|
|
156
|
+
|
|
157
|
+
# Parse with jq
|
|
158
|
+
api search --json '{"query":"AI"}' --client Openclaw | \
|
|
159
|
+
jq -r '.results.web[] | .title'
|
|
160
|
+
|
|
161
|
+
# Extract livecrawl content
|
|
162
|
+
api search --json '{
|
|
163
|
+
"query":"docs",
|
|
164
|
+
"livecrawl":"web",
|
|
165
|
+
"livecrawl_formats":"markdown"
|
|
166
|
+
}' --client Openclaw | \
|
|
167
|
+
jq -r '.results.web[0].contents.markdown'
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
**Available search parameters** (use `--schema` to see full schema):
|
|
171
|
+
- `query` (required) - Search query string
|
|
172
|
+
- `count` - Max results per section (1-100)
|
|
173
|
+
- `offset` - Pagination offset (0-9)
|
|
174
|
+
- `freshness` - day/week/month/year or date range (YYYY-MM-DDtoYYYY-MM-DD)
|
|
175
|
+
- `country` - Country code (e.g., US, GB)
|
|
176
|
+
- `safesearch` - off/moderate/strict
|
|
177
|
+
- `site` - Filter to specific domain
|
|
178
|
+
- `fileType` - Filter by file type
|
|
179
|
+
- `language` - ISO 639-1 language code
|
|
180
|
+
- `exclude_terms` - Exclude terms (pipe-separated)
|
|
181
|
+
- `exact_terms` - Exact match terms (pipe-separated)
|
|
182
|
+
- `livecrawl` - Live-crawl sections: web/news/all
|
|
183
|
+
- `livecrawl_formats` - html/markdown
|
|
184
|
+
|
|
185
|
+
### Express Command
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
api express --json '{"input":"..."}' [options]
|
|
189
|
+
|
|
190
|
+
Examples:
|
|
191
|
+
# Fast answer
|
|
192
|
+
api express --json '{"input":"What is quantum computing?"}' --client Openclaw
|
|
193
|
+
|
|
194
|
+
# Answer with web search
|
|
195
|
+
api express --json '{
|
|
196
|
+
"input":"Latest AI news",
|
|
197
|
+
"tools":[{"type":"web_search"}]
|
|
198
|
+
}' --client Openclaw
|
|
199
|
+
|
|
200
|
+
# Parse answer and sources
|
|
201
|
+
api express --json '{
|
|
202
|
+
"input":"AI trends",
|
|
203
|
+
"tools":[{"type":"web_search"}]
|
|
204
|
+
}' --client Openclaw | \
|
|
205
|
+
jq -r '.answer, "\nSources:", (.results.web[]? | "- \(.title)")'
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
**Available express parameters** (use `--schema` to see full schema):
|
|
209
|
+
- `input` (required) - Question or prompt for AI
|
|
210
|
+
- `tools` - Array of tools: `[{"type":"web_search"}]`
|
|
211
|
+
|
|
212
|
+
### Contents Command
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
api contents --json '{"urls":["..."]}' [options]
|
|
216
|
+
|
|
217
|
+
Examples:
|
|
218
|
+
# Extract markdown
|
|
219
|
+
api contents --json '{
|
|
220
|
+
"urls":["https://example.com"],
|
|
221
|
+
"formats":["markdown"]
|
|
222
|
+
}' --client Openclaw
|
|
223
|
+
|
|
224
|
+
# Multiple formats
|
|
225
|
+
api contents --json '{
|
|
226
|
+
"urls":["https://example.com"],
|
|
227
|
+
"formats":["markdown","html","metadata"]
|
|
228
|
+
}' --client Openclaw
|
|
229
|
+
|
|
230
|
+
# Multiple URLs
|
|
231
|
+
api contents --json '{
|
|
232
|
+
"urls":["https://a.com","https://b.com"],
|
|
233
|
+
"formats":["markdown"]
|
|
234
|
+
}' --client Openclaw
|
|
235
|
+
|
|
236
|
+
# Save to file
|
|
237
|
+
api contents --json '{
|
|
238
|
+
"urls":["https://example.com"],
|
|
239
|
+
"formats":["markdown"]
|
|
240
|
+
}' --client Openclaw | \
|
|
241
|
+
jq -r '.[0].markdown' > output.md
|
|
242
|
+
|
|
243
|
+
# With timeout
|
|
244
|
+
api contents --json '{
|
|
245
|
+
"urls":["https://example.com"],
|
|
246
|
+
"formats":["markdown","metadata"],
|
|
247
|
+
"crawl_timeout":30
|
|
248
|
+
}' --client Openclaw
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
**Available contents parameters** (use `--schema` to see full schema):
|
|
252
|
+
- `urls` (required) - Array of URLs to extract
|
|
253
|
+
- `formats` - Array of formats: markdown, html, metadata
|
|
254
|
+
- `crawl_timeout` - Timeout in seconds (1-60)
|
|
255
|
+
|
|
256
|
+
## Output Format
|
|
257
|
+
|
|
258
|
+
**Stdout/stderr separation** - The CLI uses stream separation to indicate success/failure:
|
|
259
|
+
|
|
260
|
+
- **Success** (exit code 0): Direct API response on stdout
|
|
261
|
+
```json
|
|
262
|
+
{"results":{"web":[...]},"metadata":{...}}
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
- **Error** (exit code 1): Error message + mailto link on stderr
|
|
266
|
+
```
|
|
267
|
+
Error: --json flag is required
|
|
268
|
+
at searchCommand (/path/to/search.ts:26:11)
|
|
269
|
+
mailto:support@you.com?subject=API%20Issue%20CLI...
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
- **Invalid args** (exit code 2): Error message on stderr
|
|
273
|
+
|
|
274
|
+
**No wrapper** - Success responses contain the direct API response without a wrapper. This makes bash pipelines simpler:
|
|
275
|
+
|
|
276
|
+
```bash
|
|
277
|
+
# Direct access to response fields
|
|
278
|
+
api search --json '{"query":"AI"}' | jq '.results.web[0].title'
|
|
279
|
+
|
|
280
|
+
# No need to unwrap .data or .success
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
## Environment Variables
|
|
284
|
+
|
|
285
|
+
- `YDC_API_KEY` - You.com API key (required)
|
|
286
|
+
- `YDC_CLIENT` - Default client name for tracking
|
|
287
|
+
|
|
288
|
+
## CLI Exit Codes
|
|
289
|
+
|
|
290
|
+
- `0` - Success (response on stdout)
|
|
291
|
+
- `1` - API error (rate limit, auth, network) - error on stderr
|
|
292
|
+
- `2` - Invalid arguments - error on stderr
|
|
293
|
+
|
|
294
|
+
## Programmatic API
|
|
295
|
+
|
|
296
|
+
### Search
|
|
297
|
+
|
|
298
|
+
```typescript
|
|
299
|
+
import { fetchSearchResults, SearchQuerySchema } from '@youdotcom-oss/api';
|
|
300
|
+
|
|
301
|
+
const getUserAgent = (client: string) => `MyApp/${client} (You.com; 1.0.0)`;
|
|
302
|
+
|
|
303
|
+
const response = await fetchSearchResults({
|
|
304
|
+
searchQuery: {
|
|
305
|
+
query: 'AI developments',
|
|
306
|
+
count: 10,
|
|
307
|
+
livecrawl: 'web',
|
|
308
|
+
livecrawl_formats: 'markdown',
|
|
309
|
+
},
|
|
310
|
+
YDC_API_KEY: process.env.YDC_API_KEY,
|
|
311
|
+
getUserAgent,
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
// Access results
|
|
315
|
+
console.log(response.results.web); // Web results with optional contents
|
|
316
|
+
console.log(response.results.news); // News results
|
|
317
|
+
console.log(response.metadata); // Query metadata
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
### Express
|
|
321
|
+
|
|
322
|
+
```typescript
|
|
323
|
+
import { callExpressAgent, ExpressAgentInputSchema } from '@youdotcom-oss/api';
|
|
324
|
+
|
|
325
|
+
const response = await callExpressAgent({
|
|
326
|
+
agentInput: {
|
|
327
|
+
input: 'What happened in AI this week?',
|
|
328
|
+
tools: [{ type: 'web_search' }],
|
|
329
|
+
},
|
|
330
|
+
YDC_API_KEY: process.env.YDC_API_KEY,
|
|
331
|
+
getUserAgent,
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
console.log(response.answer); // AI answer
|
|
335
|
+
console.log(response.results?.web); // Optional search results
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
### Contents
|
|
339
|
+
|
|
340
|
+
```typescript
|
|
341
|
+
import { fetchContents, ContentsQuerySchema } from '@youdotcom-oss/api';
|
|
342
|
+
|
|
343
|
+
const response = await fetchContents({
|
|
344
|
+
contentsQuery: {
|
|
345
|
+
urls: ['https://example.com'],
|
|
346
|
+
formats: ['markdown', 'html', 'metadata'],
|
|
347
|
+
},
|
|
348
|
+
YDC_API_KEY: process.env.YDC_API_KEY,
|
|
349
|
+
getUserAgent,
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
console.log(response[0].markdown); // Markdown content
|
|
353
|
+
console.log(response[0].html); // HTML content
|
|
354
|
+
console.log(response[0].metadata); // Structured metadata
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
## Bash Integration
|
|
358
|
+
|
|
359
|
+
### Error Handling
|
|
360
|
+
|
|
361
|
+
```bash
|
|
362
|
+
#!/usr/bin/env bash
|
|
363
|
+
set -e
|
|
364
|
+
|
|
365
|
+
# Capture result, check exit code
|
|
366
|
+
if ! result=$(api search --json '{"query":"AI developments"}' --client Openclaw); then
|
|
367
|
+
echo "Search failed with code $?"
|
|
368
|
+
exit 1
|
|
369
|
+
fi
|
|
370
|
+
|
|
371
|
+
# Parse success response from stdout
|
|
372
|
+
echo "$result" | jq .
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
### Retry on Rate Limit
|
|
376
|
+
|
|
377
|
+
```bash
|
|
378
|
+
#!/usr/bin/env bash
|
|
379
|
+
for i in {1..3}; do
|
|
380
|
+
if api search --json '{"query":"AI"}' --client Openclaw; then
|
|
381
|
+
exit 0
|
|
382
|
+
fi
|
|
383
|
+
[ $i -lt 3 ] && sleep 5
|
|
384
|
+
done
|
|
385
|
+
echo "Failed after 3 attempts"
|
|
386
|
+
exit 1
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
### Parallel Execution
|
|
390
|
+
|
|
391
|
+
```bash
|
|
392
|
+
#!/usr/bin/env bash
|
|
393
|
+
api search --json '{"query":"AI"}' --client Openclaw &
|
|
394
|
+
api search --json '{"query":"ML"}' --client Openclaw &
|
|
395
|
+
api search --json '{"query":"LLM"}' --client Openclaw &
|
|
396
|
+
wait
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
### Agent Workflow
|
|
400
|
+
|
|
401
|
+
```bash
|
|
402
|
+
#!/usr/bin/env bash
|
|
403
|
+
set -e
|
|
404
|
+
|
|
405
|
+
# Search with livecrawl
|
|
406
|
+
search=$(api search --json '{
|
|
407
|
+
"query":"AI 2026",
|
|
408
|
+
"count":5,
|
|
409
|
+
"livecrawl":"web",
|
|
410
|
+
"livecrawl_formats":"markdown"
|
|
411
|
+
}' --client Openclaw)
|
|
412
|
+
|
|
413
|
+
# Get AI answer with web search
|
|
414
|
+
answer=$(api express --json '{
|
|
415
|
+
"input":"Summarize AI developments",
|
|
416
|
+
"tools":[{"type":"web_search"}]
|
|
417
|
+
}' --client Openclaw)
|
|
418
|
+
|
|
419
|
+
# Extract top result URL and fetch content
|
|
420
|
+
url=$(echo "$search" | jq -r '.results.web[0].url')
|
|
421
|
+
api contents --json "{\"urls\":[\"$url\"],\"formats\":[\"markdown\"]}" \
|
|
422
|
+
--client Openclaw | jq -r '.[0].markdown' > output.md
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
### Schema-Driven Agent
|
|
426
|
+
|
|
427
|
+
```bash
|
|
428
|
+
#!/usr/bin/env bash
|
|
429
|
+
set -e
|
|
430
|
+
|
|
431
|
+
# Discover available search parameters
|
|
432
|
+
schema=$(api search --schema)
|
|
433
|
+
echo "$schema" | jq '.properties | keys'
|
|
434
|
+
|
|
435
|
+
# Build query dynamically
|
|
436
|
+
query=$(jq -n '{
|
|
437
|
+
query: "AI developments",
|
|
438
|
+
count: 10,
|
|
439
|
+
livecrawl: "web",
|
|
440
|
+
livecrawl_formats: "markdown"
|
|
441
|
+
}')
|
|
442
|
+
|
|
443
|
+
# Execute search
|
|
444
|
+
api search --json "$query" --client Openclaw
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
## Agent Skills Integration
|
|
448
|
+
|
|
449
|
+
This package is designed for agents that support the [Agent Skills Spec](https://agentskills.io/home). The **youdotcom-cli** skill provides guided workflows for agents to integrate You.com capabilities.
|
|
450
|
+
|
|
451
|
+
### What Agents Get
|
|
452
|
+
|
|
453
|
+
The [youdotcom-cli skill](https://github.com/youdotcom-oss/agent-skills/tree/main/skills/youdotcom-cli) teaches agents:
|
|
454
|
+
|
|
455
|
+
- **Schema Discovery** - Use `--schema` to discover available parameters
|
|
456
|
+
- **Runtime Setup** - Check for Node.js/Bun, install if needed
|
|
457
|
+
- **API Configuration** - Set up API keys and client tracking
|
|
458
|
+
- **Command Patterns** - JSON-only input with compact output
|
|
459
|
+
- **Error Handling** - Stdout/stderr separation with exit codes
|
|
460
|
+
- **Advanced Workflows** - Livecrawl, parallel execution, rate limiting
|
|
461
|
+
|
|
462
|
+
### Compatible Agents
|
|
463
|
+
|
|
464
|
+
Works with any bash-capable agent supporting Agent Skills:
|
|
465
|
+
- **OpenClaw** - Open source bash agent
|
|
466
|
+
- **Claude Code** - Anthropic's coding tool
|
|
467
|
+
- **Codex** - OpenAI's CLI agent
|
|
468
|
+
- **Cursor** - AI-powered code editor
|
|
469
|
+
- **Roo Code** - VS Code extension
|
|
470
|
+
- And more...
|
|
471
|
+
|
|
472
|
+
### Installation for Agents
|
|
473
|
+
|
|
474
|
+
```bash
|
|
475
|
+
# Add skill to agent's skills directory
|
|
476
|
+
npx skills add youdotcom-oss/agent-skills --skill youdotcom-cli
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
**Using the CLI**: See the skill's SKILL.md for complete integration workflow.
|
|
480
|
+
|
|
481
|
+
## TypeScript Types
|
|
482
|
+
|
|
483
|
+
All functions are fully typed with TypeScript. Import types alongside functions:
|
|
484
|
+
|
|
485
|
+
```typescript
|
|
486
|
+
import type {
|
|
487
|
+
SearchQuery,
|
|
488
|
+
SearchResponse,
|
|
489
|
+
ExpressAgentInput,
|
|
490
|
+
ExpressAgentMcpResponse,
|
|
491
|
+
ContentsQuery,
|
|
492
|
+
ContentsApiResponse,
|
|
493
|
+
} from '@youdotcom-oss/api';
|
|
494
|
+
```
|
|
495
|
+
|
|
496
|
+
## Error Handling
|
|
497
|
+
|
|
498
|
+
All API functions throw descriptive errors:
|
|
499
|
+
|
|
500
|
+
```typescript
|
|
501
|
+
try {
|
|
502
|
+
const results = await fetchSearchResults({
|
|
503
|
+
searchQuery: { query: 'test' },
|
|
504
|
+
YDC_API_KEY: process.env.YDC_API_KEY,
|
|
505
|
+
getUserAgent,
|
|
506
|
+
});
|
|
507
|
+
} catch (error) {
|
|
508
|
+
if (error.message.includes('Rate limited')) {
|
|
509
|
+
// Handle rate limit
|
|
510
|
+
} else if (error.message.includes('Forbidden')) {
|
|
511
|
+
// Handle auth error
|
|
512
|
+
} else {
|
|
513
|
+
// Handle other errors
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
```
|
|
517
|
+
|
|
518
|
+
## Development
|
|
519
|
+
|
|
520
|
+
```bash
|
|
521
|
+
# Install dependencies
|
|
522
|
+
bun install
|
|
523
|
+
|
|
524
|
+
# Build CLI
|
|
525
|
+
bun run build
|
|
526
|
+
|
|
527
|
+
# Run tests
|
|
528
|
+
bun test
|
|
529
|
+
|
|
530
|
+
# Type check
|
|
531
|
+
bun run check:types
|
|
532
|
+
|
|
533
|
+
# Format code
|
|
534
|
+
bun run format
|
|
535
|
+
```
|
|
536
|
+
|
|
537
|
+
## Related Packages
|
|
538
|
+
|
|
539
|
+
- [@youdotcom-oss/mcp](https://www.npmjs.com/package/@youdotcom-oss/mcp) - Model Context Protocol server
|
|
540
|
+
- [@youdotcom-oss/ai-sdk-plugin](https://www.npmjs.com/package/@youdotcom-oss/ai-sdk-plugin) - Vercel AI SDK integration
|
|
541
|
+
|
|
542
|
+
## Support
|
|
543
|
+
|
|
544
|
+
- **Issues**: [GitHub Issues](https://github.com/youdotcom-oss/dx-toolkit/issues)
|
|
545
|
+
- **API Keys**: https://you.com/platform/api-keys
|
|
546
|
+
- **Documentation**: https://github.com/youdotcom-oss/dx-toolkit/tree/main/packages/api
|
|
547
|
+
- **Email**: support@you.com
|
|
548
|
+
|
|
549
|
+
## License
|
|
550
|
+
|
|
551
|
+
MIT © You.com
|