@youdotcom-oss/api 0.1.1 → 0.2.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 +36 -36
- package/bin/cli.js +233 -400
- package/package.json +1 -1
- package/src/cli.ts +92 -21
- package/src/contents/contents.schemas.ts +8 -7
- package/src/contents/tests/contents.request.spec.ts +109 -0
- package/src/contents/tests/contents.schema-validation.spec.ts +75 -0
- package/src/deep-search/deep-search.schemas.ts +48 -0
- package/src/deep-search/deep-search.utils.ts +79 -0
- package/src/deep-search/tests/deep-search.request.spec.ts +109 -0
- package/src/deep-search/tests/deep-search.schema-validation.spec.ts +71 -0
- package/src/deep-search/tests/deep-search.utils.docker.ts +139 -0
- package/src/main.ts +4 -3
- package/src/search/search.schemas.ts +65 -6
- package/src/search/search.utils.ts +6 -28
- package/src/search/tests/search.request.spec.ts +122 -0
- package/src/search/tests/search.schema-validation.spec.ts +152 -0
- package/src/search/tests/{search.utils.spec.ts → search.utils.docker.ts} +0 -10
- package/src/shared/api.constants.ts +1 -1
- package/src/shared/check-response-for-errors.ts +1 -1
- package/src/shared/command-runner.ts +95 -0
- package/src/shared/dry-run-utils.ts +141 -0
- package/src/shared/tests/command-runner.spec.ts +210 -0
- package/src/shared/use-get-user-agents.ts +1 -1
- package/src/commands/contents.ts +0 -52
- package/src/commands/express.ts +0 -52
- package/src/commands/search.ts +0 -52
- package/src/express/express.schemas.ts +0 -85
- package/src/express/express.utils.ts +0 -113
- package/src/express/tests/express.utils.spec.ts +0 -83
- /package/src/contents/tests/{contents.utils.spec.ts → contents.utils.docker.ts} +0 -0
package/README.md
CHANGED
|
@@ -25,10 +25,10 @@ bunx @youdotcom-oss/api search --json '{"query":"AI developments"}' --client Ope
|
|
|
25
25
|
bun i -g @youdotcom-oss/api
|
|
26
26
|
ydc search --json '{"query":"AI developments"}' --client Openclaw
|
|
27
27
|
|
|
28
|
-
# Get
|
|
29
|
-
bunx @youdotcom-oss/api
|
|
30
|
-
"
|
|
31
|
-
"
|
|
28
|
+
# Get comprehensive research with citations
|
|
29
|
+
bunx @youdotcom-oss/api deep-search --json '{
|
|
30
|
+
"query":"What happened in AI this week?",
|
|
31
|
+
"search_effort":"high"
|
|
32
32
|
}' --client MyAgent
|
|
33
33
|
|
|
34
34
|
# Extract web content
|
|
@@ -100,7 +100,7 @@ All commands require the `--json` flag with a JSON string containing the query p
|
|
|
100
100
|
|
|
101
101
|
```bash
|
|
102
102
|
ydc search --json '{"query":"..."}'
|
|
103
|
-
ydc
|
|
103
|
+
ydc deep-search --json '{"query":"...","search_effort":"medium"}'
|
|
104
104
|
ydc contents --json '{"urls":["..."]}'
|
|
105
105
|
```
|
|
106
106
|
|
|
@@ -110,6 +110,7 @@ ydc contents --json '{"urls":["..."]}'
|
|
|
110
110
|
- `--api-key <key>` - You.com API key (overrides YDC_API_KEY)
|
|
111
111
|
- `--client <name>` - Client name for tracking (overrides YDC_CLIENT)
|
|
112
112
|
- `--schema` - Output JSON schema for what can be passed to --json
|
|
113
|
+
- `--dry-run` - Show request details without making API call
|
|
113
114
|
- `--help, -h` - Show help
|
|
114
115
|
|
|
115
116
|
### Schema Discovery
|
|
@@ -120,8 +121,8 @@ Use `--schema` to discover what parameters each command accepts:
|
|
|
120
121
|
# Get schema for search command
|
|
121
122
|
ydc search --schema
|
|
122
123
|
|
|
123
|
-
# Get schema for
|
|
124
|
-
ydc
|
|
124
|
+
# Get schema for deep-search command
|
|
125
|
+
ydc deep-search --schema
|
|
125
126
|
|
|
126
127
|
# Get schema for contents command
|
|
127
128
|
ydc contents --schema
|
|
@@ -182,32 +183,31 @@ Examples:
|
|
|
182
183
|
- `livecrawl` - Live-crawl sections: web/news/all
|
|
183
184
|
- `livecrawl_formats` - html/markdown
|
|
184
185
|
|
|
185
|
-
###
|
|
186
|
+
### Deep-Search Command
|
|
186
187
|
|
|
187
188
|
```bash
|
|
188
|
-
ydc
|
|
189
|
+
ydc deep-search --json '{"query":"..."}' [options]
|
|
189
190
|
|
|
190
191
|
Examples:
|
|
191
|
-
#
|
|
192
|
-
api
|
|
192
|
+
# Comprehensive research with medium effort
|
|
193
|
+
api deep-search --json '{"query":"What is quantum computing?"}' --client Openclaw
|
|
193
194
|
|
|
194
|
-
#
|
|
195
|
-
api
|
|
196
|
-
"
|
|
197
|
-
"
|
|
195
|
+
# High-effort deep research (up to 5 minutes)
|
|
196
|
+
api deep-search --json '{
|
|
197
|
+
"query":"Latest breakthroughs in AI agents",
|
|
198
|
+
"search_effort":"high"
|
|
198
199
|
}' --client Openclaw
|
|
199
200
|
|
|
200
201
|
# Parse answer and sources
|
|
201
|
-
api
|
|
202
|
-
"
|
|
203
|
-
"tools":[{"type":"web_search"}]
|
|
202
|
+
api deep-search --json '{
|
|
203
|
+
"query":"AI trends 2026"
|
|
204
204
|
}' --client Openclaw | \
|
|
205
|
-
jq -r '.answer, "\nSources:", (.results
|
|
205
|
+
jq -r '.answer, "\nSources:", (.results[]? | "- \(.title): \(.url)")'
|
|
206
206
|
```
|
|
207
207
|
|
|
208
|
-
**Available
|
|
209
|
-
- `
|
|
210
|
-
- `
|
|
208
|
+
**Available deep-search parameters** (use `--schema` to see full schema):
|
|
209
|
+
- `query` (required) - Research question requiring in-depth investigation
|
|
210
|
+
- `search_effort` - Computation budget: `low` (<30s), `medium` (<60s, default), `high` (<300s)
|
|
211
211
|
|
|
212
212
|
### Contents Command
|
|
213
213
|
|
|
@@ -317,22 +317,22 @@ console.log(response.results.news); // News results
|
|
|
317
317
|
console.log(response.metadata); // Query metadata
|
|
318
318
|
```
|
|
319
319
|
|
|
320
|
-
###
|
|
320
|
+
### Deep-Search
|
|
321
321
|
|
|
322
322
|
```typescript
|
|
323
|
-
import {
|
|
323
|
+
import { callDeepSearch, DeepSearchQuerySchema } from '@youdotcom-oss/api';
|
|
324
324
|
|
|
325
|
-
const response = await
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
325
|
+
const response = await callDeepSearch({
|
|
326
|
+
deepSearchQuery: {
|
|
327
|
+
query: 'What happened in AI this week?',
|
|
328
|
+
search_effort: 'high', // low | medium | high
|
|
329
329
|
},
|
|
330
330
|
YDC_API_KEY: process.env.YDC_API_KEY,
|
|
331
331
|
getUserAgent,
|
|
332
332
|
});
|
|
333
333
|
|
|
334
|
-
console.log(response.answer); //
|
|
335
|
-
console.log(response.results
|
|
334
|
+
console.log(response.answer); // Comprehensive answer with inline citations
|
|
335
|
+
console.log(response.results); // Array of sources with URLs, titles, and snippets
|
|
336
336
|
```
|
|
337
337
|
|
|
338
338
|
### Contents
|
|
@@ -410,10 +410,10 @@ search=$(api search --json '{
|
|
|
410
410
|
"livecrawl_formats":"markdown"
|
|
411
411
|
}' --client Openclaw)
|
|
412
412
|
|
|
413
|
-
# Get
|
|
414
|
-
answer=$(api
|
|
415
|
-
"
|
|
416
|
-
"
|
|
413
|
+
# Get comprehensive research with citations
|
|
414
|
+
answer=$(api deep-search --json '{
|
|
415
|
+
"query":"Summarize AI developments in 2026",
|
|
416
|
+
"search_effort":"high"
|
|
417
417
|
}' --client Openclaw)
|
|
418
418
|
|
|
419
419
|
# Extract top result URL and fetch content
|
|
@@ -486,8 +486,8 @@ All functions are fully typed with TypeScript. Import types alongside functions:
|
|
|
486
486
|
import type {
|
|
487
487
|
SearchQuery,
|
|
488
488
|
SearchResponse,
|
|
489
|
-
|
|
490
|
-
|
|
489
|
+
DeepSearchQuery,
|
|
490
|
+
DeepSearchResponse,
|
|
491
491
|
ContentsQuery,
|
|
492
492
|
ContentsApiResponse,
|
|
493
493
|
} from '@youdotcom-oss/api';
|