@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.
- package/dist/ai-tools.d.ts +35 -0
- package/dist/ai-tools.js +69 -0
- package/dist/api/ai.d.ts +7 -12
- package/dist/api/ai.js +2 -10
- package/dist/docs/API_SUMMARY.md +343 -1
- package/dist/docs/ai.md +79 -0
- package/dist/docs/app-manifest.md +702 -702
- package/dist/docs/host-dependency-contract.md +21 -6
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/openapi.yaml +484 -6
- package/dist/shared-dependencies.d.ts +3 -3
- package/dist/shared-dependencies.js +16 -6
- package/dist/types/ai.d.ts +323 -0
- package/dist/types/appManifest.d.ts +1 -1
- package/docs/API_SUMMARY.md +343 -1
- package/docs/ai.md +79 -0
- package/docs/app-manifest.md +702 -702
- package/docs/host-dependency-contract.md +21 -6
- package/openapi.yaml +484 -6
- package/package.json +3 -2
- package/scripts/doctor.mjs +4 -19
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { AiToolName, AiToolCapability } from './types/ai.js';
|
|
2
|
+
export interface BuiltinAiToolDescriptor {
|
|
3
|
+
/** Canonical tool name, e.g. 'web.search'. */
|
|
4
|
+
name: AiToolName;
|
|
5
|
+
/** One-line summary of what the tool does (mirrors the server registry). */
|
|
6
|
+
description: string;
|
|
7
|
+
/** Capability tags the tool requires. */
|
|
8
|
+
capabilities: AiToolCapability[];
|
|
9
|
+
/** Grouping for tool-picker UIs. */
|
|
10
|
+
group: 'web' | 'vision' | 'image' | 'media' | 'net' | 'text';
|
|
11
|
+
}
|
|
12
|
+
/** Stable name constants — reference tools without stringly-typed literals. */
|
|
13
|
+
export declare const AI_TOOL_NAMES: {
|
|
14
|
+
readonly WEB_FETCH_PAGE: "web.fetchPage";
|
|
15
|
+
readonly WEB_EXTRACT_SCHEMA: "web.extractSchema";
|
|
16
|
+
readonly WEB_SCREENSHOT: "web.screenshot";
|
|
17
|
+
readonly WEB_SEARCH: "web.search";
|
|
18
|
+
readonly BRAND_ASSETS: "brand.assets";
|
|
19
|
+
readonly DOCUMENT_READ: "document.read";
|
|
20
|
+
readonly DATA_EXTRACT: "data.extract";
|
|
21
|
+
readonly IMAGE_DESCRIBE: "image.describe";
|
|
22
|
+
readonly IMAGE_GENERATE: "image.generate";
|
|
23
|
+
readonly IMAGE_FROM_REFERENCE: "image.fromReference";
|
|
24
|
+
readonly IMAGE_SEARCH_STOCK: "image.searchStock";
|
|
25
|
+
readonly IMAGE_TRANSFORM: "image.transform";
|
|
26
|
+
readonly PDF_CREATE: "pdf.create";
|
|
27
|
+
readonly PDF_FILL: "pdf.fill";
|
|
28
|
+
readonly PDF_MERGE: "pdf.merge";
|
|
29
|
+
readonly HTTP_REQUEST: "http.request";
|
|
30
|
+
readonly TRANSLATE: "translate";
|
|
31
|
+
};
|
|
32
|
+
/** The curated core toolset shipped with the SDK. */
|
|
33
|
+
export declare const BUILTIN_AI_TOOLS: BuiltinAiToolDescriptor[];
|
|
34
|
+
/** Look up a core tool descriptor by name. */
|
|
35
|
+
export declare function getBuiltinAiTool(name: AiToolName): BuiltinAiToolDescriptor | undefined;
|
package/dist/ai-tools.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// src/ai-tools.ts
|
|
2
|
+
//
|
|
3
|
+
// The core built-in AI tools, as a typed, design-time catalog. Apps learn the core
|
|
4
|
+
// tools from HERE (autocomplete + docs), not by probing an endpoint — so they know
|
|
5
|
+
// what exists and how to call it at build time. The server-side registry
|
|
6
|
+
// (GET /ai/catalog) remains the runtime source of truth and is where future
|
|
7
|
+
// app-contributed tools appear; this list is the curated, tested core set that ships
|
|
8
|
+
// with the SDK. Adding a core tool is a deliberate change here plus a version bump.
|
|
9
|
+
/** Stable name constants — reference tools without stringly-typed literals. */
|
|
10
|
+
export const AI_TOOL_NAMES = {
|
|
11
|
+
WEB_FETCH_PAGE: 'web.fetchPage',
|
|
12
|
+
WEB_EXTRACT_SCHEMA: 'web.extractSchema',
|
|
13
|
+
WEB_SCREENSHOT: 'web.screenshot',
|
|
14
|
+
WEB_SEARCH: 'web.search',
|
|
15
|
+
BRAND_ASSETS: 'brand.assets',
|
|
16
|
+
DOCUMENT_READ: 'document.read',
|
|
17
|
+
DATA_EXTRACT: 'data.extract',
|
|
18
|
+
IMAGE_DESCRIBE: 'image.describe',
|
|
19
|
+
IMAGE_GENERATE: 'image.generate',
|
|
20
|
+
IMAGE_FROM_REFERENCE: 'image.fromReference',
|
|
21
|
+
IMAGE_SEARCH_STOCK: 'image.searchStock',
|
|
22
|
+
IMAGE_TRANSFORM: 'image.transform',
|
|
23
|
+
PDF_CREATE: 'pdf.create',
|
|
24
|
+
PDF_FILL: 'pdf.fill',
|
|
25
|
+
PDF_MERGE: 'pdf.merge',
|
|
26
|
+
HTTP_REQUEST: 'http.request',
|
|
27
|
+
TRANSLATE: 'translate',
|
|
28
|
+
};
|
|
29
|
+
/** The curated core toolset shipped with the SDK. */
|
|
30
|
+
export const BUILTIN_AI_TOOLS = [
|
|
31
|
+
{ name: 'web.search', group: 'web', capabilities: ['web:read'],
|
|
32
|
+
description: 'Search the live web; returns candidate results (url/title/description) to then read.' },
|
|
33
|
+
{ name: 'web.fetchPage', group: 'web', capabilities: ['web:read'],
|
|
34
|
+
description: 'Fetch a web page and return clean markdown, metadata, and any schema.org JSON-LD.' },
|
|
35
|
+
{ name: 'web.extractSchema', group: 'web', capabilities: ['web:read'],
|
|
36
|
+
description: 'Fetch a URL and return only its schema.org structured data of a given @type (deterministic).' },
|
|
37
|
+
{ name: 'document.read', group: 'web', capabilities: ['web:read'],
|
|
38
|
+
description: 'Read a document at a URL — PDF, deck, doc, or article — into clean markdown text.' },
|
|
39
|
+
{ name: 'data.extract', group: 'web', capabilities: ['web:read'],
|
|
40
|
+
description: 'Extract typed JSON from a page given a schema and/or prompt — turn a page into UI data.' },
|
|
41
|
+
{ name: 'brand.assets', group: 'web', capabilities: ['web:read'],
|
|
42
|
+
description: "Extract a site's brand elements — logo, colours, design — plus page metadata." },
|
|
43
|
+
{ name: 'web.screenshot', group: 'web', capabilities: ['web:read'],
|
|
44
|
+
description: 'Capture a page screenshot; returns a hosted image URL you can read with image.describe.' },
|
|
45
|
+
{ name: 'image.describe', group: 'vision', capabilities: ['ai:vision'],
|
|
46
|
+
description: 'Describe an image or read its text (vision / image-to-text).' },
|
|
47
|
+
{ name: 'image.generate', group: 'image', capabilities: ['ai:image'],
|
|
48
|
+
description: 'Generate a new image from a text prompt; returns a hosted image URL.' },
|
|
49
|
+
{ name: 'image.fromReference', group: 'image', capabilities: ['ai:image'],
|
|
50
|
+
description: 'Generate an image guided by reference image(s) plus a prompt (image-to-image).' },
|
|
51
|
+
{ name: 'image.searchStock', group: 'image', capabilities: ['ai:image'],
|
|
52
|
+
description: 'Search stock photography (Unsplash) for real photos matching a query.' },
|
|
53
|
+
{ name: 'image.transform', group: 'media', capabilities: ['media:image'],
|
|
54
|
+
description: 'Transform an image: resize/crop/rotate/flip/grayscale/tint/format-convert/compress → hosted URL.' },
|
|
55
|
+
{ name: 'pdf.create', group: 'media', capabilities: ['media:pdf'],
|
|
56
|
+
description: 'Render HTML to a PDF and return a hosted URL.' },
|
|
57
|
+
{ name: 'pdf.fill', group: 'media', capabilities: ['media:pdf'],
|
|
58
|
+
description: 'Fill an AcroForm PDF\'s fields from a { field: value } map → hosted URL.' },
|
|
59
|
+
{ name: 'pdf.merge', group: 'media', capabilities: ['media:pdf'],
|
|
60
|
+
description: 'Merge several PDFs (by URL) into one → hosted URL.' },
|
|
61
|
+
{ name: 'http.request', group: 'net', capabilities: ['net:http'],
|
|
62
|
+
description: 'SSRF-guarded outbound HTTP(S) request to a public URL; returns status/headers/body.' },
|
|
63
|
+
{ name: 'translate', group: 'text', capabilities: ['ai:text'],
|
|
64
|
+
description: 'Translate text into one or more target languages (generic, model-based).' },
|
|
65
|
+
];
|
|
66
|
+
/** Look up a core tool descriptor by name. */
|
|
67
|
+
export function getBuiltinAiTool(name) {
|
|
68
|
+
return BUILTIN_AI_TOOLS.find((t) => t.name === name);
|
|
69
|
+
}
|
package/dist/api/ai.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ContentPart, FunctionCall, ToolCall, ChatMessage, ToolDefinition, ResponseTool, ResponseInputItem, ResponsesRequest, ResponsesResult, ResponsesStreamEvent, ChatCompletionRequest, ChatCompletionChoice, ChatCompletionResponse, ChatCompletionChunk, AIModel, AIModelListParams, AIModelListResponse, AgentRunRequest, AgentRunResult, AgentToolsQuery, AgentToolsResponse, SkillsListResponse, CatalogResponse, DocumentChunk, IndexDocumentRequest, IndexDocumentResponse, ConfigureAssistantRequest, ConfigureAssistantResponse, PublicChatRequest, PublicChatResponse, Session, RateLimitStatus, SessionStatistics, VoiceSessionRequest, VoiceSessionResponse, EphemeralTokenRequest, EphemeralTokenResponse, TranscriptionResponse, TTSRequest, GeneratePodcastRequest, PodcastScript, GeneratePodcastResponse, PodcastStatus, AIGenerateContentRequest, AIGenerateImageRequest, AISearchPhotosRequest, AISearchPhotosPhoto } from "../types/ai.js";
|
|
2
|
-
export type { ContentPart, FunctionCall, ToolCall, ChatMessage, ToolDefinition, ResponseTool, ResponseInputItem, ResponsesRequest, ResponsesResult, ResponsesStreamEvent, ChatCompletionRequest, ChatCompletionChoice, ChatCompletionResponse, ChatCompletionChunk, AIModel, AIModelListParams, AIModelListResponse, DocumentChunk, IndexDocumentRequest, IndexDocumentResponse, ConfigureAssistantRequest, ConfigureAssistantResponse, PublicChatRequest, PublicChatResponse, Session, RateLimitStatus, SessionStatistics, VoiceSessionRequest, VoiceSessionResponse, EphemeralTokenRequest, EphemeralTokenResponse, TranscriptionResponse, TTSRequest, GeneratePodcastRequest, PodcastScript, GeneratePodcastResponse, PodcastStatus, AIGenerateContentRequest, AIGenerateImageRequest, AISearchPhotosRequest, AISearchPhotosPhoto, };
|
|
1
|
+
import type { ContentPart, FunctionCall, ToolCall, ChatMessage, ToolDefinition, ResponseTool, ResponseInputItem, ResponsesRequest, ResponsesResult, ResponsesStreamEvent, ChatCompletionRequest, ChatCompletionChoice, ChatCompletionResponse, ChatCompletionChunk, AIModel, AIModelListParams, AIModelListResponse, AgentRunRequest, AgentRunResult, AgentToolsQuery, AgentToolsResponse, SkillsListResponse, CatalogResponse, DocumentChunk, IndexDocumentRequest, IndexDocumentResponse, ConfigureAssistantRequest, ConfigureAssistantResponse, PublicChatRequest, PublicChatResponse, Session, RateLimitStatus, SessionStatistics, VoiceSessionRequest, VoiceSessionResponse, EphemeralTokenRequest, EphemeralTokenResponse, TranscriptionResponse, TTSRequest, GeneratePodcastRequest, PodcastScript, GeneratePodcastResponse, PodcastStatus, AIGenerateContentRequest, AIGenerateContentCandidate, AIGenerateContentResponse, AIGenerateImageRequest, AIGenerateImageResponse, AIGeneratedImage, AISearchPhotosRequest, AISearchPhotosPhoto, AISearchPhotosResponse, AIUploadedFile, AICacheRef } from "../types/ai.js";
|
|
2
|
+
export type { ContentPart, FunctionCall, ToolCall, ChatMessage, ToolDefinition, ResponseTool, ResponseInputItem, ResponsesRequest, ResponsesResult, ResponsesStreamEvent, ChatCompletionRequest, ChatCompletionChoice, ChatCompletionResponse, ChatCompletionChunk, AIModel, AIModelListParams, AIModelListResponse, DocumentChunk, IndexDocumentRequest, IndexDocumentResponse, ConfigureAssistantRequest, ConfigureAssistantResponse, PublicChatRequest, PublicChatResponse, Session, RateLimitStatus, SessionStatistics, VoiceSessionRequest, VoiceSessionResponse, EphemeralTokenRequest, EphemeralTokenResponse, TranscriptionResponse, TTSRequest, GeneratePodcastRequest, PodcastScript, GeneratePodcastResponse, PodcastStatus, AIGenerateContentRequest, AIGenerateContentCandidate, AIGenerateContentResponse, AIGenerateImageRequest, AIGenerateImageResponse, AIGeneratedImage, AISearchPhotosRequest, AISearchPhotosPhoto, AISearchPhotosResponse, AIUploadedFile, AICacheRef, };
|
|
3
3
|
declare namespace aiInternal {
|
|
4
4
|
namespace chat {
|
|
5
5
|
namespace responses {
|
|
@@ -141,27 +141,23 @@ declare namespace aiInternal {
|
|
|
141
141
|
* Generate text/content via AI (admin)
|
|
142
142
|
* @deprecated Use ai.chat.completions.create() instead
|
|
143
143
|
*/
|
|
144
|
-
function generateContent(collectionId: string, params: AIGenerateContentRequest, admin?: boolean): Promise<
|
|
144
|
+
function generateContent(collectionId: string, params: AIGenerateContentRequest, admin?: boolean): Promise<AIGenerateContentResponse>;
|
|
145
145
|
/**
|
|
146
146
|
* Generate an image via AI (admin)
|
|
147
147
|
*/
|
|
148
|
-
function generateImage(collectionId: string, params: AIGenerateImageRequest): Promise<
|
|
148
|
+
function generateImage(collectionId: string, params: AIGenerateImageRequest): Promise<AIGenerateImageResponse>;
|
|
149
149
|
/**
|
|
150
150
|
* Search stock photos or similar via AI (admin)
|
|
151
151
|
*/
|
|
152
|
-
function searchPhotos(collectionId: string, params: AISearchPhotosRequest): Promise<
|
|
152
|
+
function searchPhotos(collectionId: string, params: AISearchPhotosRequest): Promise<AISearchPhotosResponse>;
|
|
153
153
|
/**
|
|
154
154
|
* Upload a file for AI usage (admin). Pass FormData for binary uploads.
|
|
155
155
|
*/
|
|
156
|
-
function uploadFile(collectionId: string, params: any): Promise<
|
|
156
|
+
function uploadFile(collectionId: string, params: any): Promise<AIUploadedFile>;
|
|
157
157
|
/**
|
|
158
158
|
* Create or warm a cache for AI (admin)
|
|
159
159
|
*/
|
|
160
|
-
function createCache(collectionId: string, params: any): Promise<
|
|
161
|
-
/**
|
|
162
|
-
* Post a chat message to the AI (admin or public)
|
|
163
|
-
*/
|
|
164
|
-
function postChat(collectionId: string, params: any, admin?: boolean): Promise<any>;
|
|
160
|
+
function createCache(collectionId: string, params: any): Promise<AICacheRef>;
|
|
165
161
|
}
|
|
166
162
|
export declare const ai: {
|
|
167
163
|
chat: {
|
|
@@ -219,5 +215,4 @@ export declare const ai: {
|
|
|
219
215
|
searchPhotos: typeof aiInternal.searchPhotos;
|
|
220
216
|
uploadFile: typeof aiInternal.uploadFile;
|
|
221
217
|
createCache: typeof aiInternal.createCache;
|
|
222
|
-
postChat: typeof aiInternal.postChat;
|
|
223
218
|
};
|
package/dist/api/ai.js
CHANGED
|
@@ -345,6 +345,7 @@ var aiInternal;
|
|
|
345
345
|
async function generateContent(collectionId, params, admin = true) {
|
|
346
346
|
const base = admin ? '/admin' : '/public';
|
|
347
347
|
const path = `${base}/collection/${encodeURIComponent(collectionId)}/ai/generateContent`;
|
|
348
|
+
// Normalised envelope — text is at candidates[0].content.parts[0].text.
|
|
348
349
|
return post(path, params);
|
|
349
350
|
}
|
|
350
351
|
aiInternal.generateContent = generateContent;
|
|
@@ -361,6 +362,7 @@ var aiInternal;
|
|
|
361
362
|
*/
|
|
362
363
|
async function searchPhotos(collectionId, params) {
|
|
363
364
|
const path = `/admin/collection/${encodeURIComponent(collectionId)}/ai/searchPhotos`;
|
|
365
|
+
// The API wraps the photos in an envelope — the array is on `.results`.
|
|
364
366
|
return post(path, params);
|
|
365
367
|
}
|
|
366
368
|
aiInternal.searchPhotos = searchPhotos;
|
|
@@ -380,15 +382,6 @@ var aiInternal;
|
|
|
380
382
|
return post(path, params);
|
|
381
383
|
}
|
|
382
384
|
aiInternal.createCache = createCache;
|
|
383
|
-
/**
|
|
384
|
-
* Post a chat message to the AI (admin or public)
|
|
385
|
-
*/
|
|
386
|
-
async function postChat(collectionId, params, admin = true) {
|
|
387
|
-
const base = admin ? '/admin' : '/public';
|
|
388
|
-
const path = `${base}/collection/${encodeURIComponent(collectionId)}/ai/postChat`;
|
|
389
|
-
return post(path, params);
|
|
390
|
-
}
|
|
391
|
-
aiInternal.postChat = postChat;
|
|
392
385
|
})(aiInternal || (aiInternal = {}));
|
|
393
386
|
export const ai = {
|
|
394
387
|
chat: {
|
|
@@ -446,5 +439,4 @@ export const ai = {
|
|
|
446
439
|
searchPhotos: aiInternal.searchPhotos,
|
|
447
440
|
uploadFile: aiInternal.uploadFile,
|
|
448
441
|
createCache: aiInternal.createCache,
|
|
449
|
-
postChat: aiInternal.postChat,
|
|
450
442
|
};
|
package/dist/docs/API_SUMMARY.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Smartlinks API Summary
|
|
2
2
|
|
|
3
|
-
Version: 2.0.
|
|
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/dist/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
|