@proveanything/smartlinks 2.0.10 → 2.0.12

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.
@@ -1,6 +1,6 @@
1
1
  # Smartlinks API Summary
2
2
 
3
- Version: 2.0.10 | Generated: 2026-09-21T16:50:28.412Z
3
+ Version: 2.0.12 | Generated: 2026-09-21T22:28:25.241Z
4
4
 
5
5
  This is a concise summary of all available API functions and types.
6
6
 
@@ -580,6 +580,11 @@ interface ResponsesRequest {
580
580
  max_concurrent_subagents?: number
581
581
  }
582
582
  service_tier?: 'auto' | 'standard' | 'flex' | 'priority'
583
+ server_tools?: boolean | AiToolName[]
584
+ allowCapabilities?: AiToolCapability[]
585
+ only?: AiToolName[]
586
+ exclude?: AiToolName[]
587
+ maxSteps?: number
583
588
  }
584
589
  ```
585
590
 
@@ -604,6 +609,7 @@ interface ResponsesResult {
604
609
  conversation?: unknown
605
610
  provider: 'openai'
606
611
  responseTime: number
612
+ _agent?: ResponsesAgentTrace
607
613
  }
608
614
  ```
609
615
 
@@ -1010,14 +1016,98 @@ interface AISearchPhotosRequest {
1010
1016
  **AISearchPhotosPhoto** (interface)
1011
1017
  ```typescript
1012
1018
  interface AISearchPhotosPhoto {
1019
+ id?: string
1013
1020
  url: string
1021
+ thumb?: string
1014
1022
  alt?: string
1023
+ width?: number
1024
+ height?: number
1015
1025
  photographer?: string
1016
1026
  photographerUrl?: string
1017
1027
  [key: string]: any
1018
1028
  }
1019
1029
  ```
1020
1030
 
1031
+ **AISearchPhotosResponse** (interface)
1032
+ ```typescript
1033
+ interface AISearchPhotosResponse {
1034
+ provider: string
1035
+ results: AISearchPhotosPhoto[]
1036
+ total?: number
1037
+ total_pages?: number
1038
+ [key: string]: any
1039
+ }
1040
+ ```
1041
+
1042
+ **AIGeneratedImage** (interface)
1043
+ ```typescript
1044
+ interface AIGeneratedImage {
1045
+ url: string | null
1046
+ b64_json: string | null
1047
+ revised_prompt?: string
1048
+ [key: string]: any
1049
+ }
1050
+ ```
1051
+
1052
+ **AIGenerateImageResponse** (interface)
1053
+ ```typescript
1054
+ interface AIGenerateImageResponse {
1055
+ provider: string
1056
+ model?: string
1057
+ images: AIGeneratedImage[]
1058
+ [key: string]: any
1059
+ }
1060
+ ```
1061
+
1062
+ **AIGenerateContentCandidate** (interface)
1063
+ ```typescript
1064
+ interface AIGenerateContentCandidate {
1065
+ content?: { parts?: Array<{ text?: string; [k: string]: any }>; role?: string; [k: string]: any }
1066
+ finishReason?: string
1067
+ [key: string]: any
1068
+ }
1069
+ ```
1070
+
1071
+ **AIGenerateContentResponse** (interface)
1072
+ ```typescript
1073
+ interface AIGenerateContentResponse {
1074
+ provider?: string
1075
+ model?: string
1076
+ candidates?: AIGenerateContentCandidate[]
1077
+ usageMetadata?: {
1078
+ promptTokenCount?: number
1079
+ candidatesTokenCount?: number
1080
+ totalTokenCount?: number
1081
+ [k: string]: any
1082
+ }
1083
+ responseTime?: number
1084
+ [key: string]: any
1085
+ }
1086
+ ```
1087
+
1088
+ **AIUploadedFile** (interface)
1089
+ ```typescript
1090
+ interface AIUploadedFile {
1091
+ name?: string
1092
+ uri?: string
1093
+ url?: string
1094
+ mimeType?: string
1095
+ sizeBytes?: number | string
1096
+ state?: string
1097
+ [key: string]: any
1098
+ }
1099
+ ```
1100
+
1101
+ **AICacheRef** (interface)
1102
+ ```typescript
1103
+ interface AICacheRef {
1104
+ name?: string
1105
+ model?: string
1106
+ expireTime?: string
1107
+ [key: string]: any
1108
+ }
1109
+ ```
1110
+
1021
1111
  **AgentRunRequest** (interface)
1022
1112
  ```typescript
1023
1113
  interface AgentRunRequest {
@@ -1104,6 +1194,258 @@ interface CatalogResponse {
1104
1194
  }
1105
1195
  ```
1106
1196
 
1197
+ **WebFetchPageArgs** (interface)
1198
+ ```typescript
1199
+ interface WebFetchPageArgs {
1200
+ url: string; type?: string; forceRefresh?: boolean
1201
+ }
1202
+ ```
1203
+
1204
+ **WebExtractSchemaArgs** (interface)
1205
+ ```typescript
1206
+ interface WebExtractSchemaArgs {
1207
+ url: string; schemaType?: string; forceRefresh?: boolean
1208
+ }
1209
+ ```
1210
+
1211
+ **WebScreenshotArgs** (interface)
1212
+ ```typescript
1213
+ interface WebScreenshotArgs {
1214
+ url: string
1215
+ }
1216
+ ```
1217
+
1218
+ **WebSearchArgs** (interface)
1219
+ ```typescript
1220
+ interface WebSearchArgs {
1221
+ query: string; limit?: number; scrapeContent?: boolean
1222
+ }
1223
+ ```
1224
+
1225
+ **BrandAssetsArgs** (interface)
1226
+ ```typescript
1227
+ interface BrandAssetsArgs {
1228
+ url: string
1229
+ }
1230
+ ```
1231
+
1232
+ **DocumentReadArgs** (interface)
1233
+ ```typescript
1234
+ interface DocumentReadArgs {
1235
+ url: string; forceRefresh?: boolean
1236
+ }
1237
+ ```
1238
+
1239
+ **DataExtractArgs** (interface)
1240
+ ```typescript
1241
+ interface DataExtractArgs {
1242
+ url: string; schema?: Record<string, any>; prompt?: string
1243
+ }
1244
+ ```
1245
+
1246
+ **ImageDescribeArgs** (interface)
1247
+ ```typescript
1248
+ interface ImageDescribeArgs {
1249
+ imageUrl: string; prompt?: string
1250
+ }
1251
+ ```
1252
+
1253
+ **ImageGenerateArgs** (interface)
1254
+ ```typescript
1255
+ interface ImageGenerateArgs {
1256
+ prompt: string; size?: string; provider?: 'openai' | 'gemini'
1257
+ }
1258
+ ```
1259
+
1260
+ **ImageFromReferenceArgs** (interface)
1261
+ ```typescript
1262
+ interface ImageFromReferenceArgs {
1263
+ prompt: string; imageUrls: string[]; size?: string; model?: string
1264
+ }
1265
+ ```
1266
+
1267
+ **ImageSearchStockArgs** (interface)
1268
+ ```typescript
1269
+ interface ImageSearchStockArgs {
1270
+ query: string; per_page?: number; orientation?: 'landscape' | 'portrait' | 'squarish'
1271
+ }
1272
+ ```
1273
+
1274
+ **ImageTransformArgs** (interface)
1275
+ ```typescript
1276
+ interface ImageTransformArgs {
1277
+ imageUrl: string
1278
+ resize?: { width?: number; height?: number; fit?: 'cover' | 'contain' | 'fill' | 'inside' | 'outside'; allowUpscale?: boolean }
1279
+ crop?: { left: number; top: number; width: number; height: number }
1280
+ rotate?: number
1281
+ flip?: boolean
1282
+ flop?: boolean
1283
+ grayscale?: boolean
1284
+ tint?: string
1285
+ modulate?: { brightness?: number; saturation?: number; hue?: number; lightness?: number }
1286
+ format?: 'jpeg' | 'png' | 'webp' | 'avif'
1287
+ quality?: number
1288
+ }
1289
+ ```
1290
+
1291
+ **PdfCreateArgs** (interface)
1292
+ ```typescript
1293
+ interface PdfCreateArgs {
1294
+ html: string; format?: string; landscape?: boolean
1295
+ }
1296
+ ```
1297
+
1298
+ **PdfFillArgs** (interface)
1299
+ ```typescript
1300
+ interface PdfFillArgs {
1301
+ url: string; fields: Record<string, string | number | boolean>; flatten?: boolean
1302
+ }
1303
+ ```
1304
+
1305
+ **PdfMergeArgs** (interface)
1306
+ ```typescript
1307
+ interface PdfMergeArgs {
1308
+ urls: string[]
1309
+ }
1310
+ ```
1311
+
1312
+ **HttpRequestArgs** (interface)
1313
+ ```typescript
1314
+ interface HttpRequestArgs {
1315
+ url: string; method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD'; headers?: Record<string, string>; body?: any
1316
+ }
1317
+ ```
1318
+
1319
+ **TranslateArgs** (interface)
1320
+ ```typescript
1321
+ interface TranslateArgs {
1322
+ text: string; targetLanguages: string[]; sourceLanguage?: string
1323
+ }
1324
+ ```
1325
+
1326
+ **AiToolArgsMap** (interface)
1327
+ ```typescript
1328
+ interface AiToolArgsMap {
1329
+ 'web.fetchPage': WebFetchPageArgs
1330
+ 'web.extractSchema': WebExtractSchemaArgs
1331
+ 'web.screenshot': WebScreenshotArgs
1332
+ 'web.search': WebSearchArgs
1333
+ 'brand.assets': BrandAssetsArgs
1334
+ 'document.read': DocumentReadArgs
1335
+ 'data.extract': DataExtractArgs
1336
+ 'image.describe': ImageDescribeArgs
1337
+ 'image.generate': ImageGenerateArgs
1338
+ 'image.fromReference': ImageFromReferenceArgs
1339
+ 'image.searchStock': ImageSearchStockArgs
1340
+ 'image.transform': ImageTransformArgs
1341
+ 'pdf.create': PdfCreateArgs
1342
+ 'pdf.fill': PdfFillArgs
1343
+ 'pdf.merge': PdfMergeArgs
1344
+ 'http.request': HttpRequestArgs
1345
+ 'translate': TranslateArgs
1346
+ }
1347
+ ```
1348
+
1349
+ **WebSearchResultItem** (interface)
1350
+ ```typescript
1351
+ interface WebSearchResultItem {
1352
+ url: string | null; title: string | null; description: string | null; markdown?: string
1353
+ }
1354
+ ```
1355
+
1356
+ **WebSearchResult** (interface)
1357
+ ```typescript
1358
+ interface WebSearchResult {
1359
+ query: string; results: WebSearchResultItem[]
1360
+ }
1361
+ ```
1362
+
1363
+ **DocumentReadResult** (interface)
1364
+ ```typescript
1365
+ interface DocumentReadResult {
1366
+ url: string; text: string | null; metadata?: any; provider?: string; cached?: boolean
1367
+ }
1368
+ ```
1369
+
1370
+ **DataExtractResult** (interface)
1371
+ ```typescript
1372
+ interface DataExtractResult {
1373
+ url: string; data: Record<string, any>
1374
+ }
1375
+ ```
1376
+
1377
+ **WebFetchPageResult** (interface)
1378
+ ```typescript
1379
+ interface WebFetchPageResult {
1380
+ url: string; markdown?: string | null; html?: string | null; metadata?: any; schemas?: any[]; provider?: string; cached?: boolean; status?: number | null
1381
+ }
1382
+ ```
1383
+
1384
+ **ImageDescribeResult** (interface)
1385
+ ```typescript
1386
+ interface ImageDescribeResult {
1387
+ imageUrl: string; text: string | null
1388
+ }
1389
+ ```
1390
+
1391
+ **HostedAssetResult** (interface)
1392
+ ```typescript
1393
+ interface HostedAssetResult {
1394
+ hostedUrl: string | null; contentType?: string; info?: { width?: number; height?: number; format?: string; size?: number }
1395
+ }
1396
+ ```
1397
+
1398
+ **HttpRequestResult** (interface)
1399
+ ```typescript
1400
+ interface HttpRequestResult {
1401
+ status: number; headers: Record<string, any>; body: any; truncated: boolean; finalUrl: string
1402
+ }
1403
+ ```
1404
+
1405
+ **TranslateResult** (interface)
1406
+ ```typescript
1407
+ interface TranslateResult {
1408
+ translations: Record<string, string>; sourceLanguage: string
1409
+ }
1410
+ ```
1411
+
1412
+ **ResponsesAgentTrace** (interface)
1413
+ ```typescript
1414
+ interface ResponsesAgentTrace {
1415
+ steps: number
1416
+ maxStepsReached: boolean
1417
+ toolResults: AgentToolResult[]
1418
+ availableTools: string[]
1419
+ }
1420
+ ```
1421
+
1422
+ **AgentToolCallEvent** (interface)
1423
+ ```typescript
1424
+ interface AgentToolCallEvent {
1425
+ type: 'agent.tool_call'; name: string; args: Record<string, any>
1426
+ }
1427
+ ```
1428
+
1429
+ **AgentToolResultEvent** (interface)
1430
+ ```typescript
1431
+ interface AgentToolResultEvent {
1432
+ type: 'agent.tool_result'; name: string; isError: boolean; result: any
1433
+ }
1434
+ ```
1435
+
1436
+ **AgentResponseCompletedEvent** (interface)
1437
+ ```typescript
1438
+ interface AgentResponseCompletedEvent {
1439
+ type: 'response.completed'; response: ResponsesResult; _agent: ResponsesAgentTrace
1440
+ }
1441
+ ```
1442
+
1443
+ **AiToolCapability** = ``
1444
+
1445
+ **AiToolName** = ``
1446
+
1447
+ **AgentStreamEvent** = ``
1448
+
1107
1449
  ### analytics
1108
1450
 
1109
1451
  **AnalyticsLocation** (interface)
package/docs/ai.md CHANGED
@@ -257,6 +257,85 @@ const response = await ai.chat.responses.create('my-collection', {
257
257
  console.log(response.output);
258
258
  ```
259
259
 
260
+ ### Server-side tools (built-in agent loop)
261
+
262
+ The example above is **client-relayed** tool calling: you define the tools, the model returns
263
+ `tool_call` requests, and *your app* executes them and sends results back. For the common tools —
264
+ reading and searching the web, vision, reading documents, generating images — the platform ships a
265
+ curated, tested **built-in toolset it runs itself**. Opt in with `server_tools` and the server
266
+ executes each tool and feeds the result back automatically, looping until the model has its answer.
267
+ You get one final response; no relay code.
268
+
269
+ ```typescript
270
+ // Enable the whole built-in toolset:
271
+ const res = await ai.chat.responses.create('my-collection', {
272
+ model: 'balanced',
273
+ input: 'Research acme.com and summarise what they sell, with their brand colours.',
274
+ server_tools: true
275
+ });
276
+ console.log(res.output_text);
277
+ console.log(res._agent.toolResults); // trace: which tools ran, with what result
278
+ ```
279
+
280
+ Scope it to specific tools (recommended — smaller blast radius, faster), by name or capability:
281
+
282
+ ```typescript
283
+ import { AI_TOOL_NAMES } from '@proveanything/smartlinks';
284
+
285
+ const res = await ai.chat.responses.create('my-collection', {
286
+ input: 'Find the current price of this product and return it as JSON.',
287
+ server_tools: [AI_TOOL_NAMES.WEB_SEARCH, AI_TOOL_NAMES.DATA_EXTRACT],
288
+ // or: allowCapabilities: ['web:read'], exclude: ['image.generate'],
289
+ maxSteps: 6 // cap model round-trips (1–12, default 8)
290
+ });
291
+ ```
292
+
293
+ **Streaming** surfaces tool progress as it happens — ideal for a "thinking…" UI. You get
294
+ `agent.tool_call` / `agent.tool_result` events, then a final `response.completed`:
295
+
296
+ ```typescript
297
+ const stream = await ai.chat.responses.create('my-collection', {
298
+ input: 'Research acme.com', server_tools: true, stream: true
299
+ });
300
+ for await (const ev of stream) {
301
+ if (ev.type === 'agent.tool_call') showStep(`Running ${ev.name}…`);
302
+ if (ev.type === 'agent.tool_result') showStep(`${ev.name} done`);
303
+ if (ev.type === 'response.completed') render(ev.response.output_text);
304
+ }
305
+ ```
306
+
307
+ `server_tools` can't be combined with `previous_response_id`/`conversation` yet — pass prior turns
308
+ in `input`.
309
+
310
+ #### Built-in tools
311
+
312
+ | Tool | Does |
313
+ |------|------|
314
+ | `web.search` | Live web search → candidate results (url/title/description). |
315
+ | `web.fetchPage` | Fetch a page → clean markdown + metadata + schema.org JSON-LD. |
316
+ | `web.extractSchema` | Return only a page's schema.org data of a given `@type` (deterministic). |
317
+ | `document.read` | Read a document at a URL — **PDF, deck, doc**, or article — into markdown. |
318
+ | `data.extract` | Page + JSON-schema/prompt → **typed JSON** (turn a page into UI data). |
319
+ | `brand.assets` | Extract a site's logo, colours, and design. |
320
+ | `web.screenshot` | Screenshot a page → hosted image URL (feed to `image.describe`). |
321
+ | `image.describe` | Vision: describe an image / read its text. |
322
+ | `image.generate` | Generate an image from a prompt → hosted URL. |
323
+ | `image.fromReference` | Image-to-image: generate guided by reference image(s). |
324
+ | `image.searchStock` | Search real stock photos (Unsplash). |
325
+ | `image.transform` | Resize / crop / rotate / grayscale / format-convert / compress → hosted URL. |
326
+ | `pdf.create` | Render HTML → PDF → hosted URL. |
327
+ | `pdf.fill` | Fill an AcroForm PDF's fields → hosted URL. |
328
+ | `pdf.merge` | Merge several PDFs into one → hosted URL. |
329
+ | `http.request` | SSRF-guarded outbound HTTP(S) to a public URL (call a REST API). |
330
+ | `translate` | Translate text into one or more languages (generic, model-based). |
331
+
332
+ Discover tools two ways:
333
+ - **Design time (typed):** import `BUILTIN_AI_TOOLS`, `AI_TOOL_NAMES`, and the per-tool arg types
334
+ (`WebSearchArgs`, `DataExtractArgs`, …) from the SDK. This is the core set — stable, versioned,
335
+ documented here.
336
+ - **Runtime (live):** `await ai.catalog(collectionId)` returns the registry as the server sees it,
337
+ including any future app-contributed tools. The built-in set above is always present.
338
+
260
339
  ### Recommended Models
261
340
 
262
341
  For agentic workflows on `v1/responses`, GPT-5.6 ships in three tiers. Pass either the full model