@sapiom/tools 0.6.2 → 0.8.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/CHANGELOG.md +35 -0
- package/README.md +17 -11
- package/dist/cjs/_client/index.d.ts +22 -2
- package/dist/cjs/_client/index.d.ts.map +1 -1
- package/dist/cjs/_client/index.js +16 -6
- package/dist/cjs/_client/index.js.map +1 -1
- package/dist/cjs/client.d.ts +46 -1
- package/dist/cjs/client.d.ts.map +1 -1
- package/dist/cjs/client.js +20 -0
- package/dist/cjs/client.js.map +1 -1
- package/dist/cjs/content-generation/index.d.ts +118 -3
- package/dist/cjs/content-generation/index.d.ts.map +1 -1
- package/dist/cjs/content-generation/index.js +200 -4
- package/dist/cjs/content-generation/index.js.map +1 -1
- package/dist/cjs/database/errors.d.ts +16 -0
- package/dist/cjs/database/errors.d.ts.map +1 -0
- package/dist/cjs/database/errors.js +36 -0
- package/dist/cjs/database/errors.js.map +1 -0
- package/dist/cjs/database/index.d.ts +101 -0
- package/dist/cjs/database/index.d.ts.map +1 -0
- package/dist/cjs/database/index.js +118 -0
- package/dist/cjs/database/index.js.map +1 -0
- package/dist/cjs/index.d.ts +8 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +13 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/search/errors.d.ts +16 -0
- package/dist/cjs/search/errors.d.ts.map +1 -0
- package/dist/cjs/search/errors.js +36 -0
- package/dist/cjs/search/errors.js.map +1 -0
- package/dist/cjs/search/index.d.ts +234 -0
- package/dist/cjs/search/index.d.ts.map +1 -0
- package/dist/cjs/search/index.js +286 -0
- package/dist/cjs/search/index.js.map +1 -0
- package/dist/cjs/stub/index.d.ts.map +1 -1
- package/dist/cjs/stub/index.js +150 -2
- package/dist/cjs/stub/index.js.map +1 -1
- package/dist/esm/_client/index.d.ts +22 -2
- package/dist/esm/_client/index.d.ts.map +1 -1
- package/dist/esm/_client/index.js +16 -6
- package/dist/esm/_client/index.js.map +1 -1
- package/dist/esm/client.d.ts +46 -1
- package/dist/esm/client.d.ts.map +1 -1
- package/dist/esm/client.js +20 -0
- package/dist/esm/client.js.map +1 -1
- package/dist/esm/content-generation/index.d.ts +118 -3
- package/dist/esm/content-generation/index.d.ts.map +1 -1
- package/dist/esm/content-generation/index.js +196 -3
- package/dist/esm/content-generation/index.js.map +1 -1
- package/dist/esm/database/errors.d.ts +16 -0
- package/dist/esm/database/errors.d.ts.map +1 -0
- package/dist/esm/database/errors.js +31 -0
- package/dist/esm/database/errors.js.map +1 -0
- package/dist/esm/database/index.d.ts +101 -0
- package/dist/esm/database/index.d.ts.map +1 -0
- package/dist/esm/database/index.js +113 -0
- package/dist/esm/database/index.js.map +1 -0
- package/dist/esm/index.d.ts +8 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +9 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/search/errors.d.ts +16 -0
- package/dist/esm/search/errors.d.ts.map +1 -0
- package/dist/esm/search/errors.js +31 -0
- package/dist/esm/search/errors.js.map +1 -0
- package/dist/esm/search/index.d.ts +234 -0
- package/dist/esm/search/index.d.ts.map +1 -0
- package/dist/esm/search/index.js +278 -0
- package/dist/esm/search/index.js.map +1 -0
- package/dist/esm/stub/index.d.ts.map +1 -1
- package/dist/esm/stub/index.js +150 -2
- package/dist/esm/stub/index.js.map +1 -1
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +11 -1
- package/src/content-generation/README.md +90 -2
- package/src/database/README.md +62 -0
- package/src/search/README.md +255 -0
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
# search
|
|
2
|
+
|
|
3
|
+
Find information across the web and beyond — searching the web, reading pages,
|
|
4
|
+
and looking up professional emails. More operations land in this namespace as
|
|
5
|
+
they ship; today it offers `webSearch`, `scrape`, and `emailSearch`.
|
|
6
|
+
|
|
7
|
+
## `webSearch` — search the web
|
|
8
|
+
|
|
9
|
+
Search the web and get a synthesized answer plus supporting results:
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
import { createClient } from "@sapiom/tools";
|
|
13
|
+
const sapiom = createClient({ apiKey: process.env.SAPIOM_API_KEY });
|
|
14
|
+
|
|
15
|
+
const hits = await sapiom.search.webSearch({ query: "what is an LLM agent?" });
|
|
16
|
+
hits.answer; // a synthesized answer
|
|
17
|
+
hits.results; // supporting results: [{ title, url, snippet }]
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Ambient import works too: `import { search } from "@sapiom/tools"`.
|
|
21
|
+
|
|
22
|
+
### Choosing what you get back
|
|
23
|
+
|
|
24
|
+
Pass `intent: "links"` for a list of relevant results instead of a synthesized
|
|
25
|
+
answer, and `depth: "deep"` for a more thorough search:
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
const hits = await sapiom.search.webSearch({
|
|
29
|
+
query: "best practices for prompt caching",
|
|
30
|
+
intent: "links",
|
|
31
|
+
depth: "deep",
|
|
32
|
+
});
|
|
33
|
+
hits.results; // [{ title, url, snippet }, …]
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Input
|
|
37
|
+
|
|
38
|
+
- `query` (required) — what to search for.
|
|
39
|
+
- `depth` (optional) — `"standard"` (default) or `"deep"` for a more thorough
|
|
40
|
+
search.
|
|
41
|
+
- `intent` (optional) — `"answer"` (default) for a synthesized answer plus
|
|
42
|
+
supporting results, or `"links"` for a list of relevant results.
|
|
43
|
+
|
|
44
|
+
### Result
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
{
|
|
48
|
+
query: string; // the query that was searched
|
|
49
|
+
answer?: string; // a synthesized answer (present for intent: "answer")
|
|
50
|
+
results: Array<{
|
|
51
|
+
title: string;
|
|
52
|
+
url: string;
|
|
53
|
+
snippet: string;
|
|
54
|
+
}>;
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## `scrape` — read a page
|
|
59
|
+
|
|
60
|
+
Read a page and return its content. By default you get markdown:
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
import { createClient } from "@sapiom/tools";
|
|
64
|
+
const sapiom = createClient({ apiKey: process.env.SAPIOM_API_KEY });
|
|
65
|
+
|
|
66
|
+
const page = await sapiom.search.scrape({ url: "https://example.com" });
|
|
67
|
+
page.markdown; // the page content as markdown
|
|
68
|
+
page.metadata.title; // the page title
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Ambient import works too: `import { search } from "@sapiom/tools"`.
|
|
72
|
+
|
|
73
|
+
### Choosing formats
|
|
74
|
+
|
|
75
|
+
Pass `formats` to get HTML, raw HTML, a screenshot, or the page's links — alone
|
|
76
|
+
or alongside markdown:
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
const page = await sapiom.search.scrape({
|
|
80
|
+
url: "https://example.com",
|
|
81
|
+
formats: ["markdown", "html", "links"],
|
|
82
|
+
});
|
|
83
|
+
page.html; // cleaned HTML
|
|
84
|
+
page.links; // string[] of links found on the page
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Each requested format is returned as its own field; a field is present only when
|
|
88
|
+
that format was requested.
|
|
89
|
+
|
|
90
|
+
### Input
|
|
91
|
+
|
|
92
|
+
- `url` (required) — the page to read.
|
|
93
|
+
- `formats` (optional) — any of `"markdown" | "html" | "rawHtml" | "screenshot" |
|
|
94
|
+
"links"`. Defaults to `["markdown"]`.
|
|
95
|
+
- `onlyMainContent` (optional) — return only the main content, dropping
|
|
96
|
+
navigation, headers, footers, and ads.
|
|
97
|
+
- `waitFor` (optional) — milliseconds to wait before reading, for content
|
|
98
|
+
rendered by JavaScript.
|
|
99
|
+
|
|
100
|
+
### Result
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
{
|
|
104
|
+
url: string; // the URL that was read
|
|
105
|
+
markdown?: string;
|
|
106
|
+
html?: string;
|
|
107
|
+
rawHtml?: string;
|
|
108
|
+
screenshot?: string;
|
|
109
|
+
links?: string[];
|
|
110
|
+
metadata: {
|
|
111
|
+
title?: string;
|
|
112
|
+
description?: string;
|
|
113
|
+
language?: string;
|
|
114
|
+
sourceUrl?: string;
|
|
115
|
+
statusCode?: number;
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
`scrape` works on HTML pages and common documents (PDF, DOCX, TXT). It is not
|
|
121
|
+
meant for images, video, or archives.
|
|
122
|
+
|
|
123
|
+
## `emailSearch` — work with professional emails
|
|
124
|
+
|
|
125
|
+
`emailSearch` groups three operations: `findEmail` (find a person's email),
|
|
126
|
+
`verifyEmail` (check an address is deliverable), and `domainSearch` (discover the
|
|
127
|
+
emails published at a company domain).
|
|
128
|
+
|
|
129
|
+
### `findEmail` — find a person's email
|
|
130
|
+
|
|
131
|
+
```typescript
|
|
132
|
+
import { createClient } from "@sapiom/tools";
|
|
133
|
+
const sapiom = createClient({ apiKey: process.env.SAPIOM_API_KEY });
|
|
134
|
+
|
|
135
|
+
const found = await sapiom.search.emailSearch.findEmail({
|
|
136
|
+
domain: "example.com",
|
|
137
|
+
firstName: "Ada",
|
|
138
|
+
lastName: "Lovelace",
|
|
139
|
+
});
|
|
140
|
+
found.email; // the discovered email, or null when none was found
|
|
141
|
+
found.score; // confidence (0–100)
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
You must give enough to identify both the person and where they work: a `domain`
|
|
145
|
+
**or** `company`, **and** either a `fullName` **or** both `firstName` and
|
|
146
|
+
`lastName`. Calling without a valid combination throws `SearchHttpError` before
|
|
147
|
+
any request is made.
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
const found = await sapiom.search.emailSearch.findEmail({
|
|
151
|
+
company: "Example Inc",
|
|
152
|
+
fullName: "Ada Lovelace",
|
|
153
|
+
});
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
#### Input
|
|
157
|
+
|
|
158
|
+
- `domain` — company domain, e.g. `"example.com"` (provide `domain` or `company`).
|
|
159
|
+
- `company` — company name (alternative to `domain`).
|
|
160
|
+
- `firstName` / `lastName` — the person's name (provide both, or use `fullName`).
|
|
161
|
+
- `fullName` — the person's full name (alternative to `firstName` + `lastName`).
|
|
162
|
+
|
|
163
|
+
#### Result
|
|
164
|
+
|
|
165
|
+
```typescript
|
|
166
|
+
{
|
|
167
|
+
email: string | null; // null when not found
|
|
168
|
+
score?: number; // confidence 0–100
|
|
169
|
+
firstName?: string;
|
|
170
|
+
lastName?: string;
|
|
171
|
+
position?: string;
|
|
172
|
+
company?: string;
|
|
173
|
+
linkedinUrl?: string;
|
|
174
|
+
verification?: { status?: string; date?: string };
|
|
175
|
+
}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### `verifyEmail` — verify deliverability
|
|
179
|
+
|
|
180
|
+
```typescript
|
|
181
|
+
const check = await sapiom.search.emailSearch.verifyEmail({
|
|
182
|
+
email: "ada@example.com",
|
|
183
|
+
});
|
|
184
|
+
check.status; // deliverability status
|
|
185
|
+
check.score; // confidence 0–100
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
#### Input
|
|
189
|
+
|
|
190
|
+
- `email` (required) — the address to verify.
|
|
191
|
+
|
|
192
|
+
#### Result
|
|
193
|
+
|
|
194
|
+
```typescript
|
|
195
|
+
{
|
|
196
|
+
email: string;
|
|
197
|
+
status?: string;
|
|
198
|
+
result?: string;
|
|
199
|
+
score?: number;
|
|
200
|
+
smtpCheck?: boolean;
|
|
201
|
+
acceptAll?: boolean; // domain accepts any address (a positive is weak)
|
|
202
|
+
disposable?: boolean;
|
|
203
|
+
webmail?: boolean;
|
|
204
|
+
}
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### `domainSearch` — discover emails at a domain
|
|
208
|
+
|
|
209
|
+
```typescript
|
|
210
|
+
const hits = await sapiom.search.emailSearch.domainSearch({
|
|
211
|
+
domain: "example.com",
|
|
212
|
+
limit: 5,
|
|
213
|
+
seniority: ["executive"],
|
|
214
|
+
department: ["engineering", "sales"],
|
|
215
|
+
});
|
|
216
|
+
hits.emails; // [{ email, type?, confidence?, firstName?, ... }, …]
|
|
217
|
+
hits.pattern; // the detected email pattern, e.g. "{first}.{last}"
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
#### Input
|
|
221
|
+
|
|
222
|
+
- `domain` (required) — the company domain to search.
|
|
223
|
+
- `limit` — max emails to return (max 100, default 10).
|
|
224
|
+
- `type` — `"personal"` or `"generic"`.
|
|
225
|
+
- `seniority` — any of `"junior" | "senior" | "executive"`.
|
|
226
|
+
- `department` — one or more departments, e.g. `["engineering", "sales"]`.
|
|
227
|
+
|
|
228
|
+
#### Result
|
|
229
|
+
|
|
230
|
+
```typescript
|
|
231
|
+
{
|
|
232
|
+
domain: string;
|
|
233
|
+
organization?: string;
|
|
234
|
+
pattern?: string;
|
|
235
|
+
acceptAll?: boolean;
|
|
236
|
+
emails: Array<{
|
|
237
|
+
email: string;
|
|
238
|
+
type?: string;
|
|
239
|
+
confidence?: number;
|
|
240
|
+
firstName?: string;
|
|
241
|
+
lastName?: string;
|
|
242
|
+
position?: string;
|
|
243
|
+
department?: string;
|
|
244
|
+
seniority?: string;
|
|
245
|
+
}>;
|
|
246
|
+
}
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
## Gotchas
|
|
250
|
+
|
|
251
|
+
- **Failed requests throw `SearchHttpError`** (carries `status` + parsed `body`),
|
|
252
|
+
exported from `@sapiom/tools`.
|
|
253
|
+
- **`findEmail` validates its inputs before calling.** An under-specified lookup
|
|
254
|
+
(missing the org or the person) throws `SearchHttpError` immediately, with no
|
|
255
|
+
network round-trip.
|