@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.
Files changed (78) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/README.md +17 -11
  3. package/dist/cjs/_client/index.d.ts +22 -2
  4. package/dist/cjs/_client/index.d.ts.map +1 -1
  5. package/dist/cjs/_client/index.js +16 -6
  6. package/dist/cjs/_client/index.js.map +1 -1
  7. package/dist/cjs/client.d.ts +46 -1
  8. package/dist/cjs/client.d.ts.map +1 -1
  9. package/dist/cjs/client.js +20 -0
  10. package/dist/cjs/client.js.map +1 -1
  11. package/dist/cjs/content-generation/index.d.ts +118 -3
  12. package/dist/cjs/content-generation/index.d.ts.map +1 -1
  13. package/dist/cjs/content-generation/index.js +200 -4
  14. package/dist/cjs/content-generation/index.js.map +1 -1
  15. package/dist/cjs/database/errors.d.ts +16 -0
  16. package/dist/cjs/database/errors.d.ts.map +1 -0
  17. package/dist/cjs/database/errors.js +36 -0
  18. package/dist/cjs/database/errors.js.map +1 -0
  19. package/dist/cjs/database/index.d.ts +101 -0
  20. package/dist/cjs/database/index.d.ts.map +1 -0
  21. package/dist/cjs/database/index.js +118 -0
  22. package/dist/cjs/database/index.js.map +1 -0
  23. package/dist/cjs/index.d.ts +8 -1
  24. package/dist/cjs/index.d.ts.map +1 -1
  25. package/dist/cjs/index.js +13 -1
  26. package/dist/cjs/index.js.map +1 -1
  27. package/dist/cjs/search/errors.d.ts +16 -0
  28. package/dist/cjs/search/errors.d.ts.map +1 -0
  29. package/dist/cjs/search/errors.js +36 -0
  30. package/dist/cjs/search/errors.js.map +1 -0
  31. package/dist/cjs/search/index.d.ts +234 -0
  32. package/dist/cjs/search/index.d.ts.map +1 -0
  33. package/dist/cjs/search/index.js +286 -0
  34. package/dist/cjs/search/index.js.map +1 -0
  35. package/dist/cjs/stub/index.d.ts.map +1 -1
  36. package/dist/cjs/stub/index.js +150 -2
  37. package/dist/cjs/stub/index.js.map +1 -1
  38. package/dist/esm/_client/index.d.ts +22 -2
  39. package/dist/esm/_client/index.d.ts.map +1 -1
  40. package/dist/esm/_client/index.js +16 -6
  41. package/dist/esm/_client/index.js.map +1 -1
  42. package/dist/esm/client.d.ts +46 -1
  43. package/dist/esm/client.d.ts.map +1 -1
  44. package/dist/esm/client.js +20 -0
  45. package/dist/esm/client.js.map +1 -1
  46. package/dist/esm/content-generation/index.d.ts +118 -3
  47. package/dist/esm/content-generation/index.d.ts.map +1 -1
  48. package/dist/esm/content-generation/index.js +196 -3
  49. package/dist/esm/content-generation/index.js.map +1 -1
  50. package/dist/esm/database/errors.d.ts +16 -0
  51. package/dist/esm/database/errors.d.ts.map +1 -0
  52. package/dist/esm/database/errors.js +31 -0
  53. package/dist/esm/database/errors.js.map +1 -0
  54. package/dist/esm/database/index.d.ts +101 -0
  55. package/dist/esm/database/index.d.ts.map +1 -0
  56. package/dist/esm/database/index.js +113 -0
  57. package/dist/esm/database/index.js.map +1 -0
  58. package/dist/esm/index.d.ts +8 -1
  59. package/dist/esm/index.d.ts.map +1 -1
  60. package/dist/esm/index.js +9 -1
  61. package/dist/esm/index.js.map +1 -1
  62. package/dist/esm/search/errors.d.ts +16 -0
  63. package/dist/esm/search/errors.d.ts.map +1 -0
  64. package/dist/esm/search/errors.js +31 -0
  65. package/dist/esm/search/errors.js.map +1 -0
  66. package/dist/esm/search/index.d.ts +234 -0
  67. package/dist/esm/search/index.d.ts.map +1 -0
  68. package/dist/esm/search/index.js +278 -0
  69. package/dist/esm/search/index.js.map +1 -0
  70. package/dist/esm/stub/index.d.ts.map +1 -1
  71. package/dist/esm/stub/index.js +150 -2
  72. package/dist/esm/stub/index.js.map +1 -1
  73. package/dist/tsconfig.cjs.tsbuildinfo +1 -1
  74. package/dist/tsconfig.esm.tsbuildinfo +1 -1
  75. package/package.json +11 -1
  76. package/src/content-generation/README.md +90 -2
  77. package/src/database/README.md +62 -0
  78. 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.